lst=[] for i in range(5): x = input("Enter the name") lst.append(x) def count(lst): greater = 0 lesser = 0 for i in lst: if len(i) >= 5: greater += 1 else: lesser += 1 return greater,lesser greater,lesser = count(lst) print("greater : {} and lesser : {}".format(greater,lesser))
Assignment : def counts(lst): more = 0 less = 0 for i in range(len(lst)): if len(lst[i]) > 5: more = more + 1 else: less = less + 1 return more, less list = [] x = int(input("How many names you want to enter:")) for k in range(x): list.append((input())) more, less = counts(list) print('Names more than 5 characters : {} and Names less than 5 characters : {}'.format(more, less)) Output : How many names you want to enter:10 amitabh shahrukh ranveer harsh naveen moushmee viral suraj ishan karan Names more than 5 characters : 5 and Names less than 5 characters : 5 Process finished with exit code 0
@@satyajitsahoo1064 If you don't specify the length of list ,then you to always add the same number of elements to the list. Ex.for i in range(5): Here you cannot add more than 5 elements to the list
def name(lst): lst2=[] count =0 for i in lst: if len(i)>=5: lst2.append(i) count = count+1 else: continue return lst2,count lst=[] for i in range (0,10): x=(input("Enter a name ")) lst.append(x) print(lst) lst2,count=name(lst) print ("Name greater than 5 letter or equals ",lst2) print ("Total number of person ",count)
Thanks Navin Reddy for this wonderful tutor. Really it's an interactive and interesting session :) Please try to give us more assignment so that we can think a lot on it. def count(list): lengthy_name=0 short_name=0 for i in list: if len(i)>5: lengthy_name+=1 print(i,end=", ",) else: short_name+=1 return lengthy_name, short_name list=[] x=int(input("Enter how many names would you like to enter:")) for k in range(x): list.append(input('Enter Name: ')) lengthy_name, short_name = count(list) print(' ') print('Names more than 5 char: {} and Names below 5 char: {}'.format(lengthy_name,short_name))
Assignment: list_names = [] n = int(input("Enter the lenght of the list: ")) for i in range (1,n+1): names = input("Enter the names: ") list_names.append(names) print("Here the list of names:", list_names) five_letters =[] for k in list_names: if len(k)>=5: five_letters.append(k) else: continue print("Here the names with more than five letters:", five_letters)
def count(lst): x=0 for i in lst: if len(i)>=6: x+=1 print('no.of names having more than 6 letters ', x) lst=[] for j in range(10): a= str(input('enter name')) lst.append(a) count(lst)
Good Evening Everyone, here I am to master Python 3, great effort by Naveen, looking up to you man. I come from 0 experience in programing, after doing lot of research about where to learn python, I ended up here... Lets Began...!
assignment 2: lst=[(input())for i in range(10)] def count(lst): k=0 for i in lst: if len(i)>5: print(i) k+=1 return k count=count(lst) print("the no is:{}".format(count))
y=[] x=int(input('how many username uw ant to enter')) for i in range(x): k=input('enter your name') j=len(k) if j>5: y.append(k) l=0 for e in y: l=l+1 print(l) hw question
Solution for the assignment qsn(display count and names with length more than 5): //10 Names from user from array import * arr=[] n=10 for i in range(n): x=input("enter the name") arr.append(x) print(arr) //Count and display the names with length more than 5 cnt=0 for j in (arr): if(len(j)>5): print("name:{},length:{}".format(j,len(j))) cnt+=1 print("Total number of names with length more than 5 is:" ,cnt)
#1 from array import * n = int(input(' enter the lenght of string = ')) list = array('i',[]) for i in range(n): x = int(input("enter the next number = ")) list.append(x) def count(): even = 0 odd = 0 for i in list: if (i%2==0): even = even +1 else: odd = odd +1 return(even,odd) print(list) e,o = count() print("even : {} and odd :{}".format(e,o))
def name(lst): for i in lst: if len(i)>5: print(i) a = [] b = int(input('enter length of list : ')) print(f'enter {b} strings :') for i in range(b): c = input() a.append(c) name(a)
assignment lst=[] i=int(input("Enter the numbers of lists:")) for k in range (i): n=input("enter the name:") lst.append(n) print(lst) lst1=[] for l in lst: count=0 for m in range(len(l)): if m < len(l): count += 1 if count >= 5: lst1.append(l) print("list count grater than five :") print(lst1)
# this program is to check the number of user inputs having len of 5 or more than lst = [] n = int(input('enter the size of the list')) for i in range(0,n): x = input('enter the next string') lst.append(x) print(lst) count = 0 for i in lst: x = len(i) print(x) if(x>=5): count = count + 1 print('the no of inputs that have length of string more than 5 are :',count)
easy solution without complexity: lst1=[] def soumith(lst): for i in lst: if len(i)>5: lst1.append(i) print(lst1) lst=['sachin','virat','dhoni',......(10 names)] soumith(lst)
@@klausop69 then you will need to define an empty list first, and then using for loop each time you ask for a input from the user and append it to the list
list = [] a = int(input("Enter the number of names you want to enter:" )) for i in range(a): names = input("Enter the names: ") list.append(names) print(list) count = 0 countless5 = 0 for i in range(a): lenght = len(list[i]) if lenght > 5: count +=1 else: countless5 +=1 print("Count of names having letters greater than 5", count)
assignment: def names(user): count = 0 for i in user: if len(i) > 5: count += 1 return count x = int(input('enter the total number of names')) lst = [] for i in range(x): x = input('enter the names') lst.append(x) print(lst) count = names(lst) print('names greater than length five are {}'.format(count))
'''Program to print names which contain more than 5 letters from given names''' def count(l): for i in l: if len(i)>5: output.append(i) else: pass print(output) l=[] output=[] i=0 while i
def display(list): print(list) for i in list: if len(i)>5: print(i) list=[] for i in range(5): name=input("enter the names") list.append(name) display(list) it takes 5names from user and print the names with more than 5 letters
Soln of assignment:- from numpy import* x=[] n=int(input('enter the length:')) for i in range(n): z=input('enter the names:') x.append(z) def count(n): a=0 for i in x: if(len(i)>5): a=a+1 print(" names of person having letters greater than 5:",i) else: pass print(" no of persons",a) count(X)
Code for assignment problem : # create the list of names x = int(input('Enter number of inputs: ')) lst = [] for i in range(x): name = input('Enter next name: ') lst.append(name) # defining the function def name(lst): x = 0 for i in lst: if len(i) >= 5: x += 1 print(x, 'names with five or more letters.') # calling the function name(lst)
def count(list): a=0 b=0 for i in range(len(list)): if len(list[i])>5: a+=1 else: b+=1 return a,b list=[] k=int(input("Enter no of names you want to enter")) for i in range (k): list.append(input("Enter a name")) a,b=count(list) print("Names > 5 = {} and names
entr = '' names = [] def count(names): return max(names, key=len) while True: inpt = input("Enter the names (Press Enter on completion): >") if inpt == entr: break names.append(inpt) print(count(names)) to be honest i searched for max() function on Google but that input part is legit made by me fully by me 😌😌
@@nehaaadarsh What error did it generate to you? @vishwas is right : print(f'even : {even} and odd : {odd}') >> even : 5 and odd : 6 f is used instead of using format. try it and reply
def name(name_list): return sum(1 for i in name_list if len(i) > 5) print('Enter 10 names: ', end='') name_lst = [input() for i in range(10)] print(name(name_lst))
Assignment def count(): counter = 0 for i in range(5): name = input('Enter name: ') if len(name) > 5: counter += 1 print(counter, "users name has length more than 5 letters") count()
Thanks! Navin for this wonderful tutorial on python. It's really easy to understand and the assignment making me much curious to learn python . def lst(User_lst): for i in User_lst: if len(i)>5: print(i) names=[] for i in range(0,10): names.append(input("Enter a name: ")) print(names) lst(names)
printing list of even and odd separately lst=[] lst_even=[] lst_odd=[] num=int(input('enter the no of elements')) for i in range(num): x=int(input()) lst.append(x) def even_odd(a): even=0 odd=0 global lst_even,lst_odd for i in a: if i%2==0: lst_even.append(i) even+=1 else: lst_odd.append(i) odd+=1 return even, odd even , odd=even_odd(lst) print('even : {} and odd : {}'.format(even,odd)) print("even no. =",lst_even) print("odd no.=",lst_odd)
# 1) Take 10 names from the user and display the names that have length greater than 5. x = int(input("Enter the number of elements: ")) list = [] for i in range(x) : list.append(str(input("Enter the element: ")))
@@skaliya5158 In List First i used input function which will run 10 times and for each input length function will be run and check the length of the input if the name have more than 5 characters it will print
lst = [] for i in range(1, 11): x = input("Enter: {} name out of 10 ".format(i)) lst.append(x) def count(lst): length = 0 for i in lst: l = len(i) if(l>5): length+=1 return length ans = count(lst) print("Total number of names with length more than 5 chracters =", ans)
#Name Count with User input def namecount(lst): for i in lst: if len(i)>5: print(i) lst=[] for i in range(0,5): n=input('Enter Name:') lst.append(n) lst namecount(lst)
1. def count(lst): 2. greater = 0 3. lesser = 0 4. for i in lst: 5. if len(i)>5: 6. greater+=1 7. else: 8. lesser +=1 9. return greater 10. lst= [input(f'enter name number {i+1}') for i in range(10)] 11. greater = count(lst) 13. print('Number of names with length greater than 5 is = {} '.format(greater))
thanks a lot for this video, Kudos to you for your initiative, I am beginning to learn. Have a question - When i tried to use even and odd (summation within if) ,it gives zeroes. is there a reason why it is doing like that. I had to use even=even+1, odd=odd+1 to get the results. please let me know, thanks again 🙂
def countname(list): count = 0 for i in list: if len(i)>5: count = count+1 print (count) list= ["Ajay","Sanjana","Tushar","Anil","Ranjana"] countname(list)
o=[] def func(lst): for i in lst: if len(i)>5: print(i) z=int(input('How many names do you want?- ')) for i in range(z): x=input('Name-') o.append(x) func(o)
Assignment Ans: def func(count): more5=0 less5=0 for i in count: if len(i)>5: more5+=1 else: less5+=1 print(more5) print(less5) count=int(input("number of names:")) lst=list() i=0 while i
1 -Take ten names from the user and then count and display the number of users Who has length more then Five letters n=int(input("Enter the numbers of Users : ")) lst=[] for i in range(n): lst.append(input('Enter the user name : ')) print(lst) lst1=[] c=0 for i in lst: if len(i)> 5 : lst1.append(i) c+=1 print("no. of user whose name is > 5 is : ",c) print(lst1)
def count(lst): counter=0 for i in lst: length=len(i) if length>4: counter+=1 return counter list=[] c= int(input('Enter the number of names: ')) for i in range(c): name=input('Enter a name: ') list.append(name) print(list) ans=count(list) print('Number of names with letter greater than 4 are: {}'.format(ans))
answer to your assignment question sir- i was having some problems while taking input from user so I defined a list of names myself- names = ['arushi','shorya','lokesh','yash'] def count(names): words = 0 for i in names: if len(i)>5: words+=1 else: pass print(words) count(names) output- 3
Printing the names as per the user input user_input = input("Enter the list numbers or elements separated by space: ") userList = user_input.split() print("user list is ", userList) for i in userList: length = len(i) if(length > 5): print("Congrats, the name ", "is ", length, "characters long.") else: print("Sorry man!! You need to rename yourself with at least six characters..") Hope it helps somebody...
Here is my code and I am loving is. Thank you sir newName = [] def checkName(): name = input('Please give us your name ') if len(name) > 5: print('Here is your name, it is greater than 5, please choose another name') newName.append(name) print(newName) else: print('Bavo! your name is accepted') checkName()
def even_odd(*args): lst = [] count = 0 for i in args: if len(i) > 5: lst.append(i) count += 1 else: pass return count, lst args = list(map(str, input().split(" "))) count, lst = even_odd(*args) print("This is the desired names: {} , and the total number is: {}".format(lst, count)) [Thanks Sir]
assignment: def list(x): count=0 for i in x: if len(i)>5: count+=1 return count lst=[] n=int(input('enter nu of elements you want in list:')) for i in range(n): ele=(input('enter:')) lst.append(ele) print('list:',lst) count=list(lst) print('peoples who has name length greater then 5:{}'.format(count))
def countletters(lst): count = 0 for i in lst: if len(i) > 5: count+=1 return count lst1 = ['Gaurav', 'Naveen', 'Raddy', 'Kalpesh', 'Mumbai'] count = countletters(lst1) print("Name count - {} which is having more than 5 char ".format(count))
Assignment: def names(lst): Names_More_than_5=[] for i in range(x): if len(lst[i])>5: Names_More_than_5.append(lst[i]) print('Number of names having length more than 5 are: ',len(Names_More_than_5)) print(Names_More_than_5) lst=[] x= int(input('enter the count of names: ')) for i in range(x): name=input('enter the name: ') lst.append(name) names(lst) (Kindly Let me know if its wrong) Thank you to Telusko
Assignement: l1=[] n=int(input('enter number of names')) for i in range(n): name=input('enter names') l1.append(name) more=0 less=0 for i in l1: if len(i)
If we add a float to the list, it doesn't give you an error, you can run the code. if the decimal value is 0 eg - 2.0 or 3.0 it will run the operation and count either as an even or odd number. But if the decimal value is not 0 eg - 2.1 or 2.2 it will count as an odd number. You can copy the following code, do the changes to the list "lst1" and see it for yourself. def count(lst): even = 0 odd = 0 for i in lst: if i %2 == 0: even += 1 else: odd += 1 return even, odd lst1 = [1, 2, 2.1, 2.0, 2.2] even, odd = count(lst1)
def check(list): for j in list: if len(j)>5: print(j) list=[] n=int(input("How many names you want ot enter?")) for i in range(n): list.append(input("Enter a name.")) check(list)
Assignment: name=[] def enter(): for i in range(5): x = input("Enter a name: ") name.append(x) return name def check(name): x = 0 for i in range(5): if len(name[i]) > 5: x += 1 return x name = enter() print(name) a = check(name) print(a)
def count(lst): for i in lst: if len(i)>5: print(i,' has more than five letters'); else: print(i,' does not have more than 5 letters'); lst=[]; l=int(input('enter the length of list of names ')); for k in range(l): naam=str(input('enter the names ')); lst.append(naam); count(lst);
def count(name): a = 0 b = 0 for i in name: for j in range(len(i)): if j>5: a = a+1 break else: b=b+1 return a,b x = int(input('how many names')) name = [] for i in range(x): y = input('enter the name ') name.append(y) z,m = count(name) print('names given by user',name) print("number of names more then five character : {} and less then five character {}".format(z,m))
n = int(input("enter the length of the list")) lst = [] for i in range(0,n): k = input("enter the values") lst.append(k) print(lst) def countlength(a): count = 0 for j in a: if (len(j)>5): count = count + 1 else: print() return count count = countlength(lst) print("no of users with more than length 5:",count)
#take input from the user in empty list as a integer and calculate it. def count(lst): even=0 odd =0 for i in lst: if i%2==0: even+=1 else: odd+=1 return even,odd
list =[] x = int(input("Number of indux in a list?")) for j in range(x): x= int(input("Gives the input please!")) list.append(x) even, odd = count(list) print(even) print(odd)
Assignment: def count(name): k = 0 for i in name: if len(i)>=5: k=k+1 return k roster=[] for j in range(10): a=input('write a name') roster.append(a) print(roster) longName=count(roster) print(longName)
Thanks @Harsh Vora for your post was able to create out of it arr =[] # to create a blank array n = int(input("enter element count for array")) for i in range(n) : x = str (input("Enter next name : ")) arr.append((x)) print(arr) def count(arr): counter_more_5 = 0 counter_less_5 = 0 for i in range (len(arr)) : if len(arr[i])>5 : counter_more_5=counter_more_5+1 else: counter_less_5=counter_less_5+1 return counter_more_5,counter_less_5 even,odd =count(arr) print("counter_more_5 : ", str (even) + " Counter_less_5 : " ,str (odd))
Easy solution to this: def people(list): list=[] x=int(input("How many people ?")) for i in range(x): list.append(input("enter the names")) for i in list: if len(i)>5: print(i) people(list)
lst = [] n= int(input("enter the length of the list")) print("enter the names one by one") for i in range(n): lst.append(input()) print(lst) def count(lst): lol=0 for i in lst: if len(i)>=5: lol+=1 print("num of the names containing more than or equal 5 letter: ",lol) count(lst)
def count(lst): n = 0 for i in lst: if len(i) > 5: n+=1 return n lst = [] x = int (input (" enter the no names ")) for a in range (x): b= input(print("enter the next name")) lst.append(b) n = count(lst) print(n)
n = int(input("enter the size of list")) list = [] for i in range(n): val = input() list.append(val) c = 0 for e in list: if len(e) > 5: c+=1 else: pass print(c)
from numpy import* arr = list() count = 0 n = int(input("enter the length of the array")) for i in range(n): x = input("enter a string ") arr.append(x) print(arr) for j in arr: if len(j)>5: count+=1 else: pass print(count)
def count(lst): for i in lst: if (i.count('')-1)>5: print('names with Letters>5 is',i) lst=[] for e in range(10): x=input('Enter the names:{}'.format(e)) lst.append(x) print(lst) count(lst)
names = [] # Taking Input from user while True : name = input('Enter a name : ') names.append(name) option = input("Do you want to add next name Yes|No") if option.lower() == 'no' : break def checkLenGreaterThan5(names): len_names = 0 name = [] for x in names: if len(x) > 5 : len_names += 1 name.append(x) return len_names , name a , b = checkLenGreaterThan5(names) print('The Number of names greater than length 5 are ' , a , ' The names are ' , *b , sep = ',')
def count(length): counting=0 for x in (length): if len(x)>5: counting+=1 return counting user_input=input("please enter a names using space") names_as_strings= user_input.split( ) length= [str for str in names_as_strings] counting= count(length) print("counting:) print(length)
l=[] n=int(input("Enter the length:")) for i in range(n): y=input("Enter:") l.append(y) for i in l: k=0 for j in i: k+=1 if k>5: print(i) else: pass Code for the assignment Qn
Assignment from an alien : print("----This program is about getting 10 names from the users and enumerate & display the names which are all exceeding more than 5 letters----") names=[] print("Enter the names below") for i in range(11): names.append(input("Enter the name:")) print(len(names),"names added to the list names") print(names) def count(names): for i in names: if len(i) < 5: continue else: print(i)
def counter(arr): cnt = 0 for j in arr: if len(j)>5: print("name : {} and length : {}".format(j,len(j))) cnt+=1 arr = [] no = int(input('please enter the number of names you want in a list')) for i in range(no): x=input('please enter a name') arr.append(x) print(arr) name = counter(arr)
lst = [] num = int(input("How many numbers you need in a list? ")) for i in range(num): x = int(input("Enter number: ")) lst.append(x) def count(lst): even = 0 odd = 0 for f in lst: if f % 2 == 0: even += 1 else: odd += 1 return even, odd even, odd = count(lst) print("Even numbers count:", even) print("Odd numbers count:", odd)
def names(lst): count = 0 for i in lst: for j in i: count += 1 if count > 5: print(i) count = 0 lst = list() n = int(input('Enter no.of persons: ')) for i in range(n): lst.append(input('Enter names: ')) print(names(lst))
print("Enter 10 names") list=[] for i in range(0,10): ele=input() list.append(ele) def display(list): for i in list: if len(i)>4: print(i) display(list)
x=int(input("enter the size of list")) A=[] for i in range(x): u=int(input("enter the list elements")) A.append(u) print(A) def evenorodd(A): for e in A: if(e%2==0): print("{} is even".format(e)) else: print("{} is odd".format(e))
def inputuser(): for i in range(number): name = input("Enter the names") lst.append(name) def callength(lst): for i in range(len(lst)): if len(lst[i]) > 5: print(lst[i]) number = int(input("Enter the number of person you want to add to the list")) lst = [] inputuser() callength(lst
def name_length(list_of_name): for i in list_of_name: if len(i) >= 5: print(i) list_of_name = [] list_of_name_length = int(input("Please enter length of your list: ")) for i in range(list_of_name_length): x = str(input("Enter a name: ")) list_of_name.append(x) print(list_of_name) name_length(list_of_name)
def namecount(*a): for i in a: if len(i)>5: print(i) namecount('arg1','arg2',.......) or or or or or or def namecount(): names=[] a=int(input('enter how many names u want to give')) for i in range(a): x=input('enter the next name:') names.append(x) for j in names: if len(j)>5: print(j) namecount()
lst=[]
for i in range(5):
x = input("Enter the name")
lst.append(x)
def count(lst):
greater = 0
lesser = 0
for i in lst:
if len(i) >= 5:
greater += 1
else:
lesser += 1
return greater,lesser
greater,lesser = count(lst)
print("greater : {} and lesser : {}".format(greater,lesser))
'f len(i) >= 5 ', assignment is more then five letter.
Unlike other tutors, watching Mr.Navin teaching never get bored.Very active and motivating.
you lie
@@6ft333 ayoo why you here😂😂😂 you learnt python??????
Assignment :
def counts(lst):
more = 0
less = 0
for i in range(len(lst)):
if len(lst[i]) > 5:
more = more + 1
else:
less = less + 1
return more, less
list = []
x = int(input("How many names you want to enter:"))
for k in range(x):
list.append((input()))
more, less = counts(list)
print('Names more than 5 characters : {} and Names less than 5 characters : {}'.format(more, less))
Output :
How many names you want to enter:10
amitabh
shahrukh
ranveer
harsh
naveen
moushmee
viral
suraj
ishan
karan
Names more than 5 characters : 5 and Names less than 5 characters : 5
Process finished with exit code 0
what if the no. of names are not defined or asked..... any no. of names to be added.
for k in range(x):
list.append((input()))
what is the need of this Mr.Harsh??
@@satyajitsahoo1064 x inputs will be taken and each time list will append i.e new inputs will be added to the list x times
@@satyajitsahoo1064 If you don't specify the length of list ,then you to always add the same number of elements to the list.
Ex.for i in range(5):
Here you cannot add more than 5 elements to the list
@@satyajitsahoo1064 to append (add) the names given by the user into the blank list [] created
def name(lst):
lst2=[]
count =0
for i in lst:
if len(i)>=5:
lst2.append(i)
count = count+1
else:
continue
return lst2,count
lst=[]
for i in range (0,10):
x=(input("Enter a name "))
lst.append(x)
print(lst)
lst2,count=name(lst)
print ("Name greater than 5 letter or equals ",lst2)
print ("Total number of person ",count)
Thanks Navin Reddy for this wonderful tutor. Really it's an interactive and interesting session :) Please try to give us more assignment so that we can think a lot on it.
def count(list):
lengthy_name=0
short_name=0
for i in list:
if len(i)>5:
lengthy_name+=1
print(i,end=", ",)
else:
short_name+=1
return lengthy_name, short_name
list=[]
x=int(input("Enter how many names would you like to enter:"))
for k in range(x):
list.append(input('Enter Name: '))
lengthy_name, short_name = count(list)
print('
')
print('Names more than 5 char: {} and Names below 5 char: {}'.format(lengthy_name,short_name))
it has and error
an*
Assignment:
list_names = []
n = int(input("Enter the lenght of the list: "))
for i in range (1,n+1):
names = input("Enter the names: ")
list_names.append(names)
print("Here the list of names:", list_names)
five_letters =[]
for k in list_names:
if len(k)>=5:
five_letters.append(k)
else:
continue
print("Here the names with more than five letters:", five_letters)
def count(lst):
x=0
for i in lst:
if len(i)>=6:
x+=1
print('no.of names having more than 6 letters ', x)
lst=[]
for j in range(10):
a= str(input('enter name'))
lst.append(a)
count(lst)
Good Evening Everyone, here I am to master Python 3, great effort by Naveen, looking up to you man.
I come from 0 experience in programing, after doing lot of research about where to learn python, I ended up here...
Lets Began...!
def count(lst):
for i in lst:
if len(i)>5:
print(i)
a=[]
print("enter the names")
for i in range (10):
name=input("")
a.append(name)
print(a)
count(a)
assignment 2:
lst=[(input())for i in range(10)]
def count(lst):
k=0
for i in lst:
if len(i)>5:
print(i)
k+=1
return k
count=count(lst)
print("the no is:{}".format(count))
name = []
for i in range(5):
name.append(input("Please enter the name"))
for i in name:
if len(i)>5:
print(i)
else:
pass
by the way, where is the function??
y=[]
x=int(input('how many username uw ant to enter'))
for i in range(x):
k=input('enter your name')
j=len(k)
if j>5:
y.append(k)
l=0
for e in y:
l=l+1
print(l)
hw question
def count(lst):
lesser =0
notlesser=0
for i in lst:
if len(i)
def count(lst):
length = 0
for i in lst:
if len(i)>=5:
length += 1
else:
pass
return length
lst = list(map(str,input("Enter the names = ").split()))
length = count(lst)
print("Names = {}".format(length))
Solution for the assignment qsn(display count and names with length more than 5):
//10 Names from user
from array import *
arr=[]
n=10
for i in range(n):
x=input("enter the name")
arr.append(x)
print(arr)
//Count and display the names with length more than 5
cnt=0
for j in (arr):
if(len(j)>5):
print("name:{},length:{}".format(j,len(j)))
cnt+=1
print("Total number of names with length more than 5 is:" ,cnt)
#1
from array import *
n = int(input(' enter the lenght of string = '))
list = array('i',[])
for i in range(n):
x = int(input("enter the next number = "))
list.append(x)
def count():
even = 0
odd = 0
for i in list:
if (i%2==0):
even = even +1
else:
odd = odd +1
return(even,odd)
print(list)
e,o = count()
print("even : {} and odd :{}".format(e,o))
thanks sir....i was trying this and got nothing..it really helped me (:
why use array tho when you can simply do with list
def name(lst):
for i in lst:
if len(i)>5:
print(i)
a = []
b = int(input('enter length of list : '))
print(f'enter {b} strings :')
for i in range(b):
c = input()
a.append(c)
name(a)
assignment
lst=[]
i=int(input("Enter the numbers of lists:"))
for k in range (i):
n=input("enter the name:")
lst.append(n)
print(lst)
lst1=[]
for l in lst:
count=0
for m in range(len(l)):
if m < len(l):
count += 1
if count >= 5:
lst1.append(l)
print("list count grater than five :")
print(lst1)
def count(x):
l = 0
for i in x:
if len(i)>5:
l+=1
print(l)
x = []
for i in range(5):
y = input('enter the name')
x.append(y)
count(x)
# this program is to check the number of user inputs having len of 5 or more than
lst = []
n = int(input('enter the size of the list'))
for i in range(0,n):
x = input('enter the next string')
lst.append(x)
print(lst)
count = 0
for i in lst:
x = len(i)
print(x)
if(x>=5):
count = count + 1
print('the no of inputs that have length of string more than 5 are :',count)
You don't use the function here know
HURRAY! WE GOT OUR WINNER.
its showing error
easy solution without complexity:
lst1=[]
def soumith(lst):
for i in lst:
if len(i)>5:
lst1.append(i)
print(lst1)
lst=['sachin','virat','dhoni',......(10 names)]
soumith(lst)
what can be done if we want the input to be taken from the User itself only. Could you please modify the code and resend it ??
@@klausop69 Use input() to read values from keyboard and store it in list and pass it to function
@@klausop69 then you will need to define an empty list first,
and then using for loop each time you ask for a input from the user and append it to the list
sir ur natural linguistic speed already 1.25x speed XD
Seriously even i experienced that on the go.
😂😂
😂😂😂😂😂
def count():
for i in range(4):
a = input("Enter a name: ")
if len(a) >= 5:
print(a)
count()
list = []
a = int(input("Enter the number of names you want to enter:" ))
for i in range(a):
names = input("Enter the names: ")
list.append(names)
print(list)
count = 0
countless5 = 0
for i in range(a):
lenght = len(list[i])
if lenght > 5:
count +=1
else:
countless5 +=1
print("Count of names having letters greater than 5", count)
Thankyou brother
assignment:
def names(user):
count = 0
for i in user:
if len(i) > 5:
count += 1
return count
x = int(input('enter the total number of names'))
lst = []
for i in range(x):
x = input('enter the names')
lst.append(x)
print(lst)
count = names(lst)
print('names greater than length five are {}'.format(count))
here in for loop, input shall be replaced with raw_input as string to be used for names
'''Program to print names which contain
more than 5 letters from given names'''
def count(l):
for i in l:
if len(i)>5:
output.append(i)
else:
pass
print(output)
l=[]
output=[]
i=0
while i
Many many thanks sir.. We are getting two great python videos in a same day 🙏🙏🤗...
def len_of_name(len):
upper=0
lower=0
for name in user:
if name.isupper():
upper+=1
elif name.islower():
lower+=1
length=upper + lower
print(length)
user=input("enter the names:")
print('The number of the names character entered is:')
len_of_name(user)
Try mine too. The channel gives playlist for Python and R, hope they will be helpful. Source codes available too.
def display(list):
print(list)
for i in list:
if len(i)>5:
print(i)
list=[]
for i in range(5):
name=input("enter the names")
list.append(name)
display(list)
it takes 5names from user and print the names with more than 5 letters
Soln of assignment:-
from numpy import*
x=[]
n=int(input('enter the length:'))
for i in range(n):
z=input('enter the names:')
x.append(z)
def count(n):
a=0
for i in x:
if(len(i)>5):
a=a+1
print("
names of person having letters greater than 5:",i)
else:
pass
print("
no of persons",a)
count(X)
Code for assignment problem :
# create the list of names
x = int(input('Enter number of inputs: '))
lst = []
for i in range(x):
name = input('Enter next name: ')
lst.append(name)
# defining the function
def name(lst):
x = 0
for i in lst:
if len(i) >= 5:
x += 1
print(x, 'names with five or more letters.')
# calling the function
name(lst)
great
bhai esme x me jitne bhi name likhate h vo sab output aa rha h
def count(list):
a=0
b=0
for i in range(len(list)):
if len(list[i])>5:
a+=1
else:
b+=1
return a,b
list=[]
k=int(input("Enter no of names you want to enter"))
for i in range (k):
list.append(input("Enter a name"))
a,b=count(list)
print("Names > 5 = {} and names
entr = ''
names = []
def count(names):
return max(names, key=len)
while True:
inpt = input("Enter the names (Press Enter on completion):
>")
if inpt == entr:
break
names.append(inpt)
print(count(names))
to be honest i searched for max() function on Google but that input part is legit made by me fully by me 😌😌
print("enter the 10 names")
def finds():
max=5
for j in range(1,10):
if max
Hi Navin. You can print the output as
print(f'Even : {even}, Odd : {odd}'). It might look easy for learners I feel.
How can it be print??
Dude it gonna generate error
@@nehaaadarsh What error did it generate to you? @vishwas is right :
print(f'even : {even} and odd : {odd}')
>> even : 5 and odd : 6
f is used instead of using format. try it and reply
@@nehaaadarsh it works fine
@@prathyushareddy8386 i agree with u we can use f instead of using format function
@@karthikeyanatmakuru1349 it work good
def name(name_list):
return sum(1 for i in name_list if len(i) > 5)
print('Enter 10 names: ', end='')
name_lst = [input() for i in range(10)]
print(name(name_lst))
can you explain why you were using sum(1) in for loop
Here "1 for i in name_list if len(I) > 5" gives 1 if name length is greater than 5 and sum function add these 1's together
You can checkout "list comprehension" for better understanding
def fun(str):
F_L=0
for chr in str:
if len(chr)>5:
F_L+=1
return F_L
val=list(input("enter your name: ").split())
res=fun(val)
print(res)
Assignment
def count():
counter = 0
for i in range(5):
name = input('Enter name: ')
if len(name) > 5:
counter += 1
print(counter, "users name has length more than 5 letters")
count()
def count(list):
name5=0
namegr5=0
for i in list:
if len(i)
Thanks! Navin for this wonderful tutorial on python. It's really easy to understand and the assignment making me much curious to learn python .
def lst(User_lst):
for i in User_lst:
if len(i)>5:
print(i)
names=[]
for i in range(0,10):
names.append(input("Enter a name: "))
print(names)
lst(names)
printing list of even and odd separately
lst=[]
lst_even=[]
lst_odd=[]
num=int(input('enter the no of elements'))
for i in range(num):
x=int(input())
lst.append(x)
def even_odd(a):
even=0
odd=0
global lst_even,lst_odd
for i in a:
if i%2==0:
lst_even.append(i)
even+=1
else:
lst_odd.append(i)
odd+=1
return even, odd
even , odd=even_odd(lst)
print('even : {} and odd : {}'.format(even,odd))
print("even no. =",lst_even)
print("odd no.=",lst_odd)
I really like the way he taught in such as small time .keep videos short, more information and accurate. thank you
# 1) Take 10 names from the user and display the names that have length greater than 5.
x = int(input("Enter the number of elements: "))
list = []
for i in range(x) :
list.append(str(input("Enter the element: ")))
# print(list)
def count(list):
for i in list:
if len(i) > 5 :
print(i)
length = count(list)
def length(name):
for i in name:
if(len(i)>=5):
print(i)
name = [str(input("Enter Name:"))for i in range(11)]
length(name)
Hii sign ' can u explain
How the 10 names added to name =[]
@@skaliya5158 In List First i used input function which will run 10 times and for each input length function will be run and check the length of the input if the name have more than 5 characters it will print
@@divyanshusingh6105
Can u tell me how u get this type kwldg its cool ":)
Pls give me some advice so that i can also get this typ of kwldg
lst = []
for i in range(1, 11):
x = input("Enter: {} name out of 10 ".format(i))
lst.append(x)
def count(lst):
length = 0
for i in lst:
l = len(i)
if(l>5):
length+=1
return length
ans = count(lst)
print("Total number of names with length more than 5 chracters =", ans)
#Name Count with User input
def namecount(lst):
for i in lst:
if len(i)>5:
print(i)
lst=[]
for i in range(0,5):
n=input('Enter Name:')
lst.append(n)
lst
namecount(lst)
1. def count(lst):
2. greater = 0
3. lesser = 0
4. for i in lst:
5. if len(i)>5:
6. greater+=1
7. else:
8. lesser +=1
9. return greater
10. lst= [input(f'enter name number {i+1}') for i in range(10)]
11. greater = count(lst)
13. print('Number of names with length greater than 5 is = {} '.format(greater))
thanks a lot for this video, Kudos to you for your initiative, I am beginning to learn. Have a question - When i tried to use even and odd (summation within if) ,it gives zeroes. is there a reason why it is doing like that. I had to use even=even+1, odd=odd+1 to get the results.
please let me know, thanks again
🙂
def name(lst):
for names in lst:
if len(names) > 5:
print(names)
li = []
for inp in range(10):
a = input()
li.append(a)
name(li)
hey bro could you help me with this video (from 1:36 - 2:30)
please bro help me out bro
n=int(input ("enter no of values to enter "))
inputs = [input() for i in range(n)]
print(inputs)
hey bro could you help me with this video (from 1:36 - 2:30)
please bro help me out bro
def countname(list):
count = 0
for i in list:
if len(i)>5:
count = count+1
print (count)
list= ["Ajay","Sanjana","Tushar","Anil","Ranjana"]
countname(list)
i love your assignments
def names(lst):
count=0
for i in lst:
if len(i)>=5:
count+=1
return count
a=0
lst = []
while(a
o=[]
def func(lst):
for i in lst:
if len(i)>5:
print(i)
z=int(input('How many names do you want?- '))
for i in range(z):
x=input('Name-')
o.append(x)
func(o)
Mine is more simple
Assignment Ans:
def func(count):
more5=0
less5=0
for i in count:
if len(i)>5:
more5+=1
else:
less5+=1
print(more5)
print(less5)
count=int(input("number of names:"))
lst=list()
i=0
while i
1 -Take ten names from the user and then count and display the number of users
Who has length more then Five letters
n=int(input("Enter the numbers of Users : "))
lst=[]
for i in range(n):
lst.append(input('Enter the user name : '))
print(lst)
lst1=[]
c=0
for i in lst:
if len(i)> 5 :
lst1.append(i)
c+=1
print("no. of user whose name is > 5 is : ",c)
print(lst1)
def count(lst):
counter=0
for i in lst:
length=len(i)
if length>4:
counter+=1
return counter
list=[]
c= int(input('Enter the number of names: '))
for i in range(c):
name=input('Enter a name: ')
list.append(name)
print(list)
ans=count(list)
print('Number of names with letter greater than 4 are: {}'.format(ans))
Sir you had made me to fall in love with Python
@Rithesh Jaiswal absolutely bro❤️
no need to use function
lst=[]
for i in range(5):
x=input("enter name:")
lst.append(x)
i=0
while i=5:
print(lst[i])
i+=1
answer to your assignment question sir- i was having some problems while taking input from user so I defined a list of names myself-
names = ['arushi','shorya','lokesh','yash']
def count(names):
words = 0
for i in names:
if len(i)>5:
words+=1
else:
pass
print(words)
count(names)
output- 3
you didn't have to write else
your code is giving an error
// try this
x=int(input())
c=0;
lst = []
for i in range(x):
y=str(input())
lst.append(y)
for i in lst:
if(len(i)>5):
c+=1
print(c)
Printing the names as per the user input
user_input = input("Enter the list numbers or elements separated by space: ")
userList = user_input.split()
print("user list is ", userList)
for i in userList:
length = len(i)
if(length > 5):
print("Congrats, the name ",
"is ", length, "characters long.")
else:
print("Sorry man!! You need to rename yourself with at least six characters..")
Hope it helps somebody...
It did❤️
Here is my code and I am loving is. Thank you sir
newName = []
def checkName():
name = input('Please give us your name ')
if len(name) > 5:
print('Here is your name, it is greater than 5, please choose another name')
newName.append(name)
print(newName)
else:
print('Bavo! your name is accepted')
checkName()
def even_odd(*args):
lst = []
count = 0
for i in args:
if len(i) > 5:
lst.append(i)
count += 1
else:
pass
return count, lst
args = list(map(str, input().split(" ")))
count, lst = even_odd(*args)
print("This is the desired names: {} , and the total number is: {}".format(lst, count))
[Thanks Sir]
assignment:
def list(x):
count=0
for i in x:
if len(i)>5:
count+=1
return count
lst=[]
n=int(input('enter nu of elements you want in list:'))
for i in range(n):
ele=(input('enter:'))
lst.append(ele)
print('list:',lst)
count=list(lst)
print('peoples who has name length greater then 5:{}'.format(count))
def countletters(lst):
count = 0
for i in lst:
if len(i) > 5:
count+=1
return count
lst1 = ['Gaurav', 'Naveen', 'Raddy', 'Kalpesh', 'Mumbai']
count = countletters(lst1)
print("Name count - {} which is having more than 5 char ".format(count))
Assignment:
def names(lst):
Names_More_than_5=[]
for i in range(x):
if len(lst[i])>5:
Names_More_than_5.append(lst[i])
print('Number of names having length more than 5 are: ',len(Names_More_than_5))
print(Names_More_than_5)
lst=[]
x= int(input('enter the count of names: '))
for i in range(x):
name=input('enter the name: ')
lst.append(name)
names(lst)
(Kindly Let me know if its wrong)
Thank you to Telusko
Assignement:
l1=[]
n=int(input('enter number of names'))
for i in range(n):
name=input('enter names')
l1.append(name)
more=0
less=0
for i in l1:
if len(i)
n=int(input("Please enter how many time user enter string:"))
j=0
d=[]
while j 5:
d.append(j)
print("List of 5 greater than letters is ",d ,"user")
If we add a float to the list, it doesn't give you an error, you can run the code.
if the decimal value is 0 eg - 2.0 or 3.0 it will run the operation and count either as an even or odd number.
But if the decimal value is not 0 eg - 2.1 or 2.2 it will count as an odd number.
You can copy the following code, do the changes to the list "lst1" and see it for yourself.
def count(lst):
even = 0
odd = 0
for i in lst:
if i %2 == 0:
even += 1
else:
odd += 1
return even, odd
lst1 = [1, 2, 2.1, 2.0, 2.2]
even, odd = count(lst1)
def check(list):
for j in list:
if len(j)>5:
print(j)
list=[]
n=int(input("How many names you want ot enter?"))
for i in range(n):
list.append(input("Enter a name."))
check(list)
Assignment Ans:
def user(names):
for name in names:
if len(name)>5:
print(name)
else:
continue
return name
names = ["Roy","meghana", "ram", "sruthi", "daivik", "valli", "srinidhi", "ramu", "swetha", "chandra"]
user(names)
Thank you ):
Navin's teaching rocks - Python shocks ):
Assignment:
name=[]
def enter():
for i in range(5):
x = input("Enter a name: ")
name.append(x)
return name
def check(name):
x = 0
for i in range(5):
if len(name[i]) > 5:
x += 1
return x
name = enter()
print(name)
a = check(name)
print(a)
def count(lst):
for i in lst:
if len(i)>5:
print(i,' has more than five letters');
else:
print(i,' does not have more than 5 letters');
lst=[];
l=int(input('enter the length of list of names
'));
for k in range(l):
naam=str(input('enter the names
'));
lst.append(naam);
count(lst);
def count(name):
a = 0
b = 0
for i in name:
for j in range(len(i)):
if j>5:
a = a+1
break
else:
b=b+1
return a,b
x = int(input('how many names'))
name = []
for i in range(x):
y = input('enter the name ')
name.append(y)
z,m = count(name)
print('names given by user',name)
print("number of names more then five character : {} and less then five character {}".format(z,m))
n = int(input("enter the length of the list"))
lst = []
for i in range(0,n):
k = input("enter the values")
lst.append(k)
print(lst)
def countlength(a):
count = 0
for j in a:
if (len(j)>5):
count = count + 1
else:
print()
return count
count = countlength(lst)
print("no of users with more than length 5:",count)
thanks a ton ! @Navin Reddy for making this beginner friendly python bootcamp. it is the best python bootcamp on the youtube
#take input from the user in empty list as a integer and calculate it.
def count(lst):
even=0
odd =0
for i in lst:
if i%2==0:
even+=1
else:
odd+=1
return even,odd
list =[]
x = int(input("Number of indux in a list?"))
for j in range(x):
x= int(input("Gives the input please!"))
list.append(x)
even, odd = count(list)
print(even)
print(odd)
Assignment:
def count(name):
k = 0
for i in name:
if len(i)>=5:
k=k+1
return k
roster=[]
for j in range(10):
a=input('write a name')
roster.append(a)
print(roster)
longName=count(roster)
print(longName)
Thanks @Harsh Vora for your post was able to create out of it
arr =[] # to create a blank array
n = int(input("enter element count for array"))
for i in range(n) :
x = str (input("Enter next name : "))
arr.append((x))
print(arr)
def count(arr):
counter_more_5 = 0
counter_less_5 = 0
for i in range (len(arr)) :
if len(arr[i])>5 :
counter_more_5=counter_more_5+1
else:
counter_less_5=counter_less_5+1
return counter_more_5,counter_less_5
even,odd =count(arr)
print("counter_more_5 : ", str (even) + " Counter_less_5 : " ,str (odd))
Easy solution to this:
def people(list):
list=[]
x=int(input("How many people ?"))
for i in range(x):
list.append(input("enter the names"))
for i in list:
if len(i)>5:
print(i)
people(list)
lst = []
n= int(input("enter the length of the list"))
print("enter the names one by one")
for i in range(n):
lst.append(input())
print(lst)
def count(lst):
lol=0
for i in lst:
if len(i)>=5:
lol+=1
print("num of the names containing more than or equal 5 letter: ",lol)
count(lst)
def count(lst):
n = 0
for i in lst:
if len(i) > 5:
n+=1
return n
lst = []
x = int (input (" enter the no names "))
for a in range (x):
b= input(print("enter the next name"))
lst.append(b)
n = count(lst)
print(n)
def count(lst):
lst1=[]
for i in lst:
if len(i)
n = int(input("enter the size of list"))
list = []
for i in range(n):
val = input()
list.append(val)
c = 0
for e in list:
if len(e) > 5:
c+=1
else:
pass
print(c)
from numpy import*
arr = list()
count = 0
n = int(input("enter the length of the array"))
for i in range(n):
x = input("enter a string ")
arr.append(x)
print(arr)
for j in arr:
if len(j)>5:
count+=1
else:
pass
print(count)
Taking no.of names also as user input and then printing it:
def name(lng):
for i in range(len(lng)):
if(len(lng[i])
def count(lst):
for i in lst:
if (i.count('')-1)>5:
print('names with Letters>5 is',i)
lst=[]
for e in range(10):
x=input('Enter the names:{}'.format(e))
lst.append(x)
print(lst)
count(lst)
names = []
# Taking Input from user
while True :
name = input('Enter a name : ')
names.append(name)
option = input("Do you want to add next name Yes|No")
if option.lower() == 'no' :
break
def checkLenGreaterThan5(names):
len_names = 0
name = []
for x in names:
if len(x) > 5 :
len_names += 1
name.append(x)
return len_names , name
a , b = checkLenGreaterThan5(names)
print('The Number of names greater than length 5 are ' , a , '
The names are ' , *b , sep = ',')
Brother y r u using *b plz explain
def count(length):
counting=0
for x in (length):
if len(x)>5:
counting+=1
return counting
user_input=input("please enter a names using space")
names_as_strings= user_input.split( )
length= [str for str in names_as_strings]
counting= count(length)
print("counting:)
print(length)
l=[]
n=int(input("Enter the length:"))
for i in range(n):
y=input("Enter:")
l.append(y)
for i in l:
k=0
for j in i:
k+=1
if k>5:
print(i)
else:
pass
Code for the assignment Qn
Def names(list)
For i in list:
If len(i)>=5
Print(i)
List[ ]
For i in range(10)
X=input(‘enter the nxt value’)
List.append(x)
Names(list)
def list(lst):
For i in lst:
For j in range(len(i)):
If j>=5:
Print(i)
lst =["any names"]
list(lst)
Assignment:
lst =[]
for j in range(4):
nm=input("enter the name")
lst.append(nm)
def play(lst):
for i in lst:
if len (i) > 5:
print(i)
play(lst)
Assignment from an alien :
print("----This program is about getting 10 names from the users and enumerate & display the names which are all exceeding more than 5 letters----")
names=[]
print("Enter the names below")
for i in range(11):
names.append(input("Enter the name:"))
print(len(names),"names added to the list names")
print(names)
def count(names):
for i in names:
if len(i) < 5:
continue
else:
print(i)
count(names)
def counter(arr):
cnt = 0
for j in arr:
if len(j)>5:
print("name : {} and length : {}".format(j,len(j)))
cnt+=1
arr = []
no = int(input('please enter the number of names you want in a list'))
for i in range(no):
x=input('please enter a name')
arr.append(x)
print(arr)
name = counter(arr)
lst = []
num = int(input("How many numbers you need in a list? "))
for i in range(num):
x = int(input("Enter number: "))
lst.append(x)
def count(lst):
even = 0
odd = 0
for f in lst:
if f % 2 == 0:
even += 1
else:
odd += 1
return even, odd
even, odd = count(lst)
print("Even numbers count:", even)
print("Odd numbers count:", odd)
def names(lst):
count = 0
for i in lst:
for j in i:
count += 1
if count > 5:
print(i)
count = 0
lst = list()
n = int(input('Enter no.of persons: '))
for i in range(n):
lst.append(input('Enter names: '))
print(names(lst))
print("Enter 10 names")
list=[]
for i in range(0,10):
ele=input()
list.append(ele)
def display(list):
for i in list:
if len(i)>4:
print(i)
display(list)
def count(Names):
for i in Names:
if (len(i)>10):
print(i)
Names= str(input("Enter names"))
string_names= Names.split(",")
count(string_names)
x=int(input("enter the size of list"))
A=[]
for i in range(x):
u=int(input("enter the list elements"))
A.append(u)
print(A)
def evenorodd(A):
for e in A:
if(e%2==0):
print("{} is even".format(e))
else:
print("{} is odd".format(e))
evenorodd(A)
def inputuser():
for i in range(number):
name = input("Enter the names")
lst.append(name)
def callength(lst):
for i in range(len(lst)):
if len(lst[i]) > 5:
print(lst[i])
number = int(input("Enter the number of person you want to add to the list"))
lst = []
inputuser()
callength(lst
def name_length(list_of_name):
for i in list_of_name:
if len(i) >= 5:
print(i)
list_of_name = []
list_of_name_length = int(input("Please enter length of your list: "))
for i in range(list_of_name_length):
x = str(input("Enter a name: "))
list_of_name.append(x)
print(list_of_name)
name_length(list_of_name)
def namecount(*a):
for i in a:
if len(i)>5:
print(i)
namecount('arg1','arg2',.......)
or or or or or or
def namecount():
names=[]
a=int(input('enter how many names u want to give'))
for i in range(a):
x=input('enter the next name:')
names.append(x)
for j in names:
if len(j)>5:
print(j)
namecount()