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

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

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

FavoriteLoadingAdd to favorites

Python Tutorial to learn Python programming with examples
Complete Python Tutorial for Beginners Playlist :
Python Tutorial in Hindi :

Github :-

Editing Monitors :

Check out our website:

Follow Telusko on Twitter:

Follow on Facebook:
Telusko :
Navin Reddy :

Follow Navin Reddy on Instagram:

Subscribe to our other channel:
Navin Reddy :
Telusko Hindi :

Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20

source

By |2020-01-01T00:56:47+00:00January 1st, 2020|Python Video Tutorials|20 Comments

20 Comments

  1. K. K Saini January 1, 2020 at 12:56 am - Reply

    assignment solution

    def count(lst):

    n = 0

    m = 0

    for i in lst:

    if len(i)>5:

    n+=1

    else:

    m+=1

    return n,m

    lst = []

    l = int(input("enter the length of list: "))

    for i in range(l):

    lst.append(input())

    print(lst)

    n, m = count(lst)

    print("no of word having more than 5 character: ", n)

    print("no of word having less & equal 5 character: ", m)

    output:
    enter the length of list: 10

    bjsd

    bdwbwjkb

    nnd

    bjehibed

    nnd

    dfgg

    bejjeien

    nfjf

    ne

    e

    ['bjsd', 'bdwbwjkb', 'nnd', 'bjehibed', 'nnd', 'dfgg', 'bejjeien', 'nfjf', 'ne', 'e']

    no of word having more than 5 character: 3

    no of word having less & equal 5 character: 7

  2. sk v January 1, 2020 at 12:56 am - Reply

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

    name=str(input("please enter name:"))

    lst.append(name)

    i+=1

    print(lst)

    func(lst)

  3. suchit kumar January 1, 2020 at 12:56 am - Reply

    lst=[]

    x=(int(input("Enter the no.of names: ")))

    for i in range(x):

    y=(input("Enter names in list: "))

    lst.append(y)

    print(lst)

    def count():

    LEF=[]

    GF=[]

    for i in lst:

    if len(i)>5:

    GF.append(i)

    else:

    LEF.append(i)

    return GF,LEF

    GF,LEF=count()

    print("names whose length>5= {},names whose length<=5={}".format(GF,LEF))

  4. ashish soni January 1, 2020 at 12:56 am - Reply

    Hello sir ,how to make video like u have made?

  5. Myanmar Educator January 1, 2020 at 12:56 am - Reply

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

  6. Shreedhar Chavan January 1, 2020 at 12:56 am - Reply

    def count(lst):
    even = 0
    odd = 0
    for i in lst:
    if int(i)%2 == 0:
    even += 1
    else:
    odd += 1
    return even,odd

    lst = [ ]
    x = int(input("How many numbers?"))
    print("Enter the values:")
    for k in range(x):
    lst.append(input())
    even, odd = count(lst)
    print("Even:{ } Odd:{ }". format (even,odd))

    Output:
    How many numbers?5
    Enter the values:
    3
    5
    12
    4
    78
    Even:3 Odd:2

  7. Swapnil Tathe January 1, 2020 at 12:56 am - Reply

    Assignment: To Show odd even numbers with Count

    def check(lst):

    even = []

    even_count = 0

    odd = []

    odd_count = 0

    for i in lst:

    if i % 2 == 0:

    even.append(i)

    even_count += 1

    else:

    odd.append(i)

    odd_count += 1

    return even, even_count, odd, odd_count

    lst = eval(input("Enter numbers by comma separated: "))

    even, even_count, odd, odd_count = check(lst)

    print("tEven numbers: {} (Count: {})ntOdd numbers: {} (Count: {})".format(str(even).strip('[]'), even_count, str(odd).strip('[]'), odd_count))

    Output:
    Enter numbers by comma separated: 1, 2, 3, 45, 56, 21, 9

    Even numbers: 2, 56 (Count: 2)

    Odd numbers: 1, 3, 45, 21, 9 (Count: 5)

  8. Deepak Vm January 1, 2020 at 12:56 am - Reply

    print("enter the 10 names")

    def finds():

    max=5

    for j in range(1,10):

    if max<len(arr[j]):

    print(arr[j])

    from array import *

    arr = [0]*10

    for i in range (0,10):

    x=input()

    arr[i]=x

    print(arr)

    finds()

  9. Shrinivas Jadhav January 1, 2020 at 12:56 am - Reply

    lst = []

    n=int(input("enter the no of list items:"))

    for i in range(0,n):

    item=int(input())

    lst.append(item)

    print("List is",lst)

  10. Aditya Tiwari January 1, 2020 at 12:56 am - Reply

    can anyone tell me how I can get the input from the user in that list..
    like i use this earlier..
    x=int (input ('Enter 1st number'))
    y=int (input ('Enter 2nd number'))
    z=int (input ('Enter 3rd  number'))
    adi=x+y+z
    print(adi)

  11. Anand kumar January 1, 2020 at 12:56 am - Reply

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

  12. SUJOY CHAND January 1, 2020 at 12:56 am - Reply

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

  13. Aman Silawat January 1, 2020 at 12:56 am - Reply

    Assignment:

    def count(lst):

    num = 0

    nameList = []

    for i in lst:

    if len(i) <= 5:

    nameList.append(i)

    num += 1

    return num, nameList

    lst = ['aman', 'mukesh', 'raju', 'balwant', 'navin', 'yogesh']

    sortName, nameList = count(lst)

    print("Total ", sortName , " names that are less than 5 characters")

    def listToString(s):

    str1 = ", "

    return (str1.join(s))

    print(listToString(nameList))

  14. R.Rajkumar January 1, 2020 at 12:56 am - Reply

    Assignment Solution:

    Userin=[]

    for i in range(1,11):

    Userin.append(input(" Enter " + str(i) + " Name = "))

    print (Userin)

    def CheckLen(Userin):

    Output_Len=[]

    for i in Userin:

    if len(i)>=5:

    Output_Len.append(i)

    else:

    pass

    return Output_Len

    List_five_Len_Users=CheckLen(Userin)

    print("Name Which has Length more than 5 ", List_five_Len_Users)

  15. price please bd January 1, 2020 at 12:56 am - Reply

    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)

  16. DR Homestead January 1, 2020 at 12:56 am - Reply

    Doubt : What is “return” ??

  17. loveunimeanit January 1, 2020 at 12:56 am - Reply

    so list is an exception from global or local assignment …

  18. sriram jallu January 1, 2020 at 12:56 am - Reply

    def countNoOfElements(persons):

    count=0

    temp =[]

    for i in persons:

    if len(i)>=5:

    temp.append(i)

    count+=1

    return count,temp

    names = []

    x = int(input("How many names you want to enter: "))

    print("enter names")

    for i in range(x):

    names.append(input())

    res1,res2 = countNoOfElements(names)

    print("number of names which have more than 5 characters are : {}".format(res1))

    print("names which have mare than 5 characters are: {}".format(res2))

  19. Gnanasekar B January 1, 2020 at 12:56 am - Reply

    lst=['Gnana','Sekar','Chandra','Narayana','Gitam']

    for i in lst:

    if len(i)==5:

    print(i)

  20. shivaan January 1, 2020 at 12:56 am - Reply

    i don't know why i am getting the error #error as —
    even, odd = count(lst)

    TypeError: count() missing 1 required positional argument: 'odd'

    def count(even, odd):

    even=0

    odd=0

    for i in lst:

    if i%2==0:

    even+=1

    else:

    odd+=1

    return even,odd

    lst=[25,89,23,56,78,45,88]

    even, odd = count(lst)

    print(even)

    print(odd)

Leave A Comment

*