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

preview_player
Показать описание
Python Tutorial to learn Python programming with examples

Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Editing Monitors :

Follow on Facebook:

Subscribe to our other channel:
Telusko Hindi :

Donation:
PayPal Id : navinreddy20
Patreon : navinreddy20
Рекомендации по теме
Комментарии
Автор

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

poojithareddy
Автор

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

tharlinhtet
Автор

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('\n')
print('Names more than 5 char: {} and Names below 5 char: {}'.format(lengthy_name, short_name))

Yash
Автор

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

devasish
Автор

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

harshvora
Автор

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)

gadgetunboxing
Автор

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

yogeshwarprasad
Автор

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

mrlokeshkumar
Автор

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)

alege
Автор

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)

Meego_
Автор

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

riaz_ay
Автор

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

hruthiksai
Автор

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

AaryanGupta-cg
Автор

sir ur natural linguistic speed already 1.25x speed XD

NikhilWhiskyKumar
Автор

Assignment:
names = [ ]
for i in range(0, 10):
m=input("Enter Name:")
names.append(m)

def count(x):
large=0
for i in names:
if len(i)>5:
large=large+1
return large
a=count(names)
print("Number of Names with length more than 5: {}".format(a))

noortusharkhan
Автор

entr = ''
names = []
def count(names):
return max(names, key=len)
while True:
inpt = input("Enter the names (Press Enter on completion):\n>")
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 😌😌

axwaizee
Автор

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)

chiragukey
Автор

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

yogeshkumarshankariya
Автор

def count(lst):
c=0
for i in lst:
if len(i)>5:
c+=1
return c
lst1=[]
for i in range(10):
lst1.append(input("enter the name"))
print(lst1)
print(count(lst1))

tirthketulpatel
Автор

lst=[]

for i in range(10):
name = input("enter the name ")
lst.append(name)
for j in lst:
if len(j)<=5:
continue
else:
print(j)

userfg