#37 Python Tutorial for Beginners | Pass List to a Function in Python

Поделиться
HTML-код
  • Опубликовано: 24 ноя 2024

Комментарии • 704

  • @poojithareddy7346
    @poojithareddy7346 4 года назад +62

    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))

    • @saadahnaf208
      @saadahnaf208 2 года назад +2

      'f len(i) >= 5 ', assignment is more then five letter.

  • @cityrunner-x3x
    @cityrunner-x3x 4 года назад +74

    Unlike other tutors, watching Mr.Navin teaching never get bored.Very active and motivating.

  • @harshvora1922
    @harshvora1922 5 лет назад +94

    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

    • @yashsharma685
      @yashsharma685 5 лет назад +2

      what if the no. of names are not defined or asked..... any no. of names to be added.

    • @satyajitsahoo1064
      @satyajitsahoo1064 5 лет назад +2

      for k in range(x):
      list.append((input()))
      what is the need of this Mr.Harsh??

    • @AJabcdefghi
      @AJabcdefghi 5 лет назад +2

      @@satyajitsahoo1064 x inputs will be taken and each time list will append i.e new inputs will be added to the list x times

    • @karthik3778
      @karthik3778 5 лет назад +2

      @@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

    • @vj729
      @vj729 4 года назад +1

      @@satyajitsahoo1064 to append (add) the names given by the user into the blank list [] created

  • @gadgetunboxing8485
    @gadgetunboxing8485 5 лет назад +12

    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)

  • @Yash8147
    @Yash8147 4 года назад +37

    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))

    • @bov._.v
      @bov._.v 10 месяцев назад

      it has and error

    • @bov._.v
      @bov._.v 10 месяцев назад

      an*

  • @ale94ge
    @ale94ge 4 года назад +8

    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)

    • @bss.
      @bss. 2 года назад +2

      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)

  • @devasish204
    @devasish204 4 года назад +20

    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...!

  • @Meego_007
    @Meego_007 6 лет назад +4

    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)

  • @riaz_ay
    @riaz_ay 4 года назад +10

    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))

  • @yogeshkumarshankariya642
    @yogeshkumarshankariya642 3 года назад +12

    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

  • @ayushsahu1475
    @ayushsahu1475 Год назад +1

    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

  • @uvishnuprasad2944
    @uvishnuprasad2944 3 года назад +1

    def count(lst):
    lesser =0
    notlesser=0
    for i in lst:
    if len(i)

  • @ainaryaravindkumar4681
    @ainaryaravindkumar4681 4 месяца назад +1

    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))

  • @kasyapmaddala7341
    @kasyapmaddala7341 4 года назад +16

    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)

  • @yogeshwarprasad6797
    @yogeshwarprasad6797 4 года назад +9

    #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))

    • @HarryPotter-jd1dx
      @HarryPotter-jd1dx 4 года назад

      thanks sir....i was trying this and got nothing..it really helped me (:

    • @puneet8705
      @puneet8705 4 года назад

      why use array tho when you can simply do with list

  • @shreeja9265
    @shreeja9265 6 лет назад +2

    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)

  • @12nov83
    @12nov83 2 года назад

    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)

  • @chiragukey7283
    @chiragukey7283 4 года назад +2

    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)

  • @hruthiksai7061
    @hruthiksai7061 4 года назад +12

    # 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)

  • @soumithjavvaji3310
    @soumithjavvaji3310 5 лет назад +15

    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
      @klausop69 4 года назад

      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 ??

    • @praveen1193
      @praveen1193 4 года назад +1

      @@klausop69 Use input() to read values from keyboard and store it in list and pass it to function

    • @puneet8705
      @puneet8705 4 года назад +1

      @@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

  • @NikhilWhiskyKumar
    @NikhilWhiskyKumar 4 года назад +66

    sir ur natural linguistic speed already 1.25x speed XD

  • @AaryanGupta-c4g
    @AaryanGupta-c4g 5 месяцев назад +2

    def count():
    for i in range(4):
    a = input("Enter a name: ")
    if len(a) >= 5:
    print(a)
    count()

  • @atulayagupta785
    @atulayagupta785 4 года назад +4

    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)

  • @BalajiSuresh1995
    @BalajiSuresh1995 5 лет назад +2

    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))

    • @prof.fauwazparkar9446
      @prof.fauwazparkar9446 4 года назад

      here in for loop, input shall be replaced with raw_input as string to be used for names

  • @aniketaher4691
    @aniketaher4691 4 года назад +1

    '''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

  • @chinmaydas4053
    @chinmaydas4053 6 лет назад +12

    Many many thanks sir.. We are getting two great python videos in a same day 🙏🙏🤗...

  • @alienyijoseph6318
    @alienyijoseph6318 Год назад +1

    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)

    • @easydatascience2508
      @easydatascience2508 Год назад

      Try mine too. The channel gives playlist for Python and R, hope they will be helpful. Source codes available too.

  • @snowbraze6299
    @snowbraze6299 4 года назад +1

    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

  • @prabalagrawal4058
    @prabalagrawal4058 4 года назад

    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)

  • @vikramsey
    @vikramsey 3 года назад +4

    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)

  • @BhuveshDhiman
    @BhuveshDhiman 5 лет назад +1

    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

  • @axwaizee9582
    @axwaizee9582 3 года назад +1

    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 😌😌

  • @deepakvm1475
    @deepakvm1475 5 лет назад

    print("enter the 10 names")
    def finds():
    max=5
    for j in range(1,10):
    if max

  • @vishwasbharadwaj9386
    @vishwasbharadwaj9386 4 года назад +20

    Hi Navin. You can print the output as
    print(f'Even : {even}, Odd : {odd}'). It might look easy for learners I feel.

    • @nehaaadarsh
      @nehaaadarsh 4 года назад +1

      How can it be print??
      Dude it gonna generate error

    • @prathyushareddy8386
      @prathyushareddy8386 4 года назад

      @@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

    • @dishantkumbhar8822
      @dishantkumbhar8822 4 года назад

      @@nehaaadarsh it works fine

    • @karthikeyanatmakuru1349
      @karthikeyanatmakuru1349 4 года назад +1

      @@prathyushareddy8386 i agree with u we can use f instead of using format function

    • @tabzeal8726
      @tabzeal8726 4 года назад

      @@karthikeyanatmakuru1349 it work good

  • @just_a_living_being
    @just_a_living_being 6 лет назад +6

    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))

    • @Maks05N
      @Maks05N 4 года назад

      can you explain why you were using sum(1) in for loop

    • @just_a_living_being
      @just_a_living_being 4 года назад

      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

    • @just_a_living_being
      @just_a_living_being 4 года назад

      You can checkout "list comprehension" for better understanding

  • @sagarsinha668
    @sagarsinha668 10 дней назад

    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)

  • @navinduabhishek8564
    @navinduabhishek8564 3 года назад

    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()

  • @cloudlyrics9344
    @cloudlyrics9344 4 года назад +1

    def count(list):
    name5=0
    namegr5=0
    for i in list:
    if len(i)

  • @YONAnYONA
    @YONAnYONA 8 месяцев назад

    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)

  • @new_beginning2571
    @new_beginning2571 4 года назад +1

    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)

  • @giveaway4002
    @giveaway4002 6 лет назад +5

    I really like the way he taught in such as small time .keep videos short, more information and accurate. thank you

  • @AdityaSingh-v6r
    @AdityaSingh-v6r 4 месяца назад

    # 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)

  • @divyanshusingh6105
    @divyanshusingh6105 4 года назад +3

    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)

    • @skaliya5158
      @skaliya5158 4 года назад +1

      Hii sign ' can u explain
      How the 10 names added to name =[]

    • @divyanshusingh6105
      @divyanshusingh6105 4 года назад

      @@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

    • @skaliya5158
      @skaliya5158 4 года назад

      @@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

  • @tushargupta6570
    @tushargupta6570 3 года назад +1

    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)

  • @harisbagwan9984
    @harisbagwan9984 4 года назад +1

    #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)

  • @Habonzgold
    @Habonzgold 5 месяцев назад

    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))

  • @deveshmaniar4383
    @deveshmaniar4383 2 года назад +2

    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
    🙂

  • @shivanshtiwary5829
    @shivanshtiwary5829 4 года назад +1

    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)

    • @Notyouranalyst
      @Notyouranalyst 3 года назад

      hey bro could you help me with this video (from 1:36 - 2:30)
      please bro help me out bro

  • @prakashreddy7277
    @prakashreddy7277 5 лет назад +3

    n=int(input ("enter no of values to enter "))
    inputs = [input() for i in range(n)]
    print(inputs)

    • @Notyouranalyst
      @Notyouranalyst 3 года назад

      hey bro could you help me with this video (from 1:36 - 2:30)
      please bro help me out bro

  • @tusharkantidebnath2316
    @tusharkantidebnath2316 4 года назад +1

    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)

  • @abhishek7882
    @abhishek7882 3 года назад

    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

    • @doserastalmi
      @doserastalmi 3 года назад

      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)

    • @doserastalmi
      @doserastalmi 3 года назад

      Mine is more simple

  • @skvytla
    @skvytla 4 года назад

    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

  • @ashwinbicholiya6691
    @ashwinbicholiya6691 4 года назад +4

    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)

  • @vainayak30
    @vainayak30 6 лет назад

    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))

  • @054_ritesh3
    @054_ritesh3 4 года назад +5

    Sir you had made me to fall in love with Python

  • @abhinaylakhera2273
    @abhinaylakhera2273 4 года назад

    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

  • @mrlokeshkumar76
    @mrlokeshkumar76 3 года назад +8

    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

    • @divyanshupandey8150
      @divyanshupandey8150 3 года назад

      you didn't have to write else

    • @vishugusain5232
      @vishugusain5232 3 года назад

      your code is giving an error

    • @akashkumarsagar1423
      @akashkumarsagar1423 3 года назад

      // 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)

  • @meerajadhikari1877
    @meerajadhikari1877 4 года назад +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...

  • @kingsleyihemere6121
    @kingsleyihemere6121 5 лет назад +2

    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()

  • @sohomdas8693
    @sohomdas8693 3 года назад

    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]

  • @hardikjambhule3952
    @hardikjambhule3952 4 года назад

    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))

  • @011gaurav
    @011gaurav 4 года назад

    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))

  • @sahilsurve5361
    @sahilsurve5361 4 года назад +1

    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

  • @riteshsarode8120
    @riteshsarode8120 4 года назад

    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)

  • @HEMANTHKUMAR-ir5hc
    @HEMANTHKUMAR-ir5hc Год назад

    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")

  • @Rajadahana
    @Rajadahana 2 года назад +1

    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)

  • @BhuveshDhiman
    @BhuveshDhiman 5 лет назад

    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)

  • @chandraroy8254
    @chandraroy8254 4 года назад +4

    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 ):

  • @narangparth
    @narangparth 4 года назад +3

    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)

  • @joyekka1382
    @joyekka1382 4 года назад

    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);

  • @saadahnaf208
    @saadahnaf208 2 года назад

    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))

  • @vishnuvirat5821
    @vishnuvirat5821 3 года назад

    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)

  • @hariomchaudhary7194
    @hariomchaudhary7194 2 года назад

    thanks a ton ! @Navin Reddy for making this beginner friendly python bootcamp. it is the best python bootcamp on the youtube

  • @FactsDiscoveryyoutube
    @FactsDiscoveryyoutube 5 лет назад +1

    #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)

  • @golshanswonderland8906
    @golshanswonderland8906 4 года назад

    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)

  • @chandsujoy
    @chandsujoy 5 лет назад

    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))

  • @jugalvaidya9476
    @jugalvaidya9476 4 года назад

    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)

  • @pricepleasebd6873
    @pricepleasebd6873 5 лет назад

    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)

  • @kuldeepnareliya4841
    @kuldeepnareliya4841 5 лет назад

    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)

  • @VijayAdhithyaramasamy
    @VijayAdhithyaramasamy 5 лет назад

    def count(lst):
    lst1=[]
    for i in lst:
    if len(i)

  • @sumansaurabh2669
    @sumansaurabh2669 4 года назад

    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)

  • @abhishekshukla6466
    @abhishekshukla6466 4 года назад

    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)

  • @shreshtkapoor97
    @shreshtkapoor97 4 года назад

    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])

  • @sagarr1640
    @sagarr1640 3 года назад

    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)

  • @rajneeshpatel5028
    @rajneeshpatel5028 4 года назад +1

    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 = ',')

    • @binaygupta478
      @binaygupta478 4 года назад

      Brother y r u using *b plz explain

  • @karangupta5401
    @karangupta5401 Год назад

    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)

  • @dhayanandshanmugam7183
    @dhayanandshanmugam7183 3 года назад +1

    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

  • @liya6313
    @liya6313 5 месяцев назад

    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)

  • @karthikeyan-gy8tn
    @karthikeyan-gy8tn 3 года назад

    def list(lst):
    For i in lst:
    For j in range(len(i)):
    If j>=5:
    Print(i)
    lst =["any names"]
    list(lst)

  • @sumanthchatra8242
    @sumanthchatra8242 4 года назад

    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)

  • @karthibalaji3817
    @karthibalaji3817 5 лет назад

    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)

  • @pimppakoda1153
    @pimppakoda1153 4 года назад

    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)

  • @adarshprasad4666
    @adarshprasad4666 5 месяцев назад

    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)

  • @abhisekdas4770
    @abhisekdas4770 4 года назад

    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))

  • @arjyabasu1311
    @arjyabasu1311 5 лет назад

    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)

  • @monausavlogs9796
    @monausavlogs9796 4 года назад

    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)

  • @prapullachandrakoganti9811
    @prapullachandrakoganti9811 4 года назад +1

    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)

  • @wicked87manu
    @wicked87manu 5 лет назад

    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

  • @ThoRBaaP
    @ThoRBaaP 3 года назад

    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)

  • @MGA0295
    @MGA0295 5 лет назад

    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()