-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex_sort_list.py
More file actions
33 lines (31 loc) · 895 Bytes
/
ex_sort_list.py
File metadata and controls
33 lines (31 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/usr/python3
#This program output as count of strings in given list
"""This program which explain use of While conditional loop,
sort list with two types of input list"""
print("\n")
a=[1,2,3,89,56,45,'Ganesh','Suresh','mahesh'] #Create a list
a_int=[]
a_str=[]
b=len(a)
print("List contain total",b,"elements:",a,"\n") # Display a list
i=z1=z2=0
while i!=b :
if type(a[i])== type('Strings'):
a_str.append(a[i])
i=i+1
z1=z1+1
#print(i,z)
else:
a_int.append(a[i])
i=i+1
z2=z2+1
print("It has ",z1,"Strings elements &",z2,"integers elements\n")
'''print(sorted(a_int)) #It returns sort of numbersand doesn't modify list
print(sorted(a_str))
print (a_int)
print (a_str)'''
#print (sorted(a_int))
a_str.sort() # Find the difference w,r,t output
a_int.sort()
finallist=a_int+a_str
print ("When sorted, list will be:",finallist)