0

Can we perform list count by creating a function? If yes, then please give an example

28th Oct 2019, 6:12 PM
S.05
S.05 - avatar
6 ответов
+ 2
Your question is not quite clear. what language you are talking about? please give a sample of input data and what you expect to get out.
28th Oct 2019, 6:22 PM
Lothar
Lothar - avatar
+ 2
You don't need to create an own function for this. lst = [1,2,3] print(len(lst)) # output : 3 # or if you need the number: lst_len = len(lst) # lst_len will be 3
28th Oct 2019, 6:41 PM
Lothar
Lothar - avatar
0
def listLength(x): print(len(x)) return(len(x)) Or public List<int> listLength (List<int> exList){ Console.WriteLine(exList.Length); Return exList; }
28th Oct 2019, 6:24 PM
Rodrigo Oliveira
Rodrigo Oliveira - avatar
0
I'm talking about python 3
28th Oct 2019, 6:25 PM
S.05
S.05 - avatar
0
My first example is for python 3.
28th Oct 2019, 6:28 PM
Rodrigo Oliveira
Rodrigo Oliveira - avatar
0
You just have to call it: listLength(your list here)
28th Oct 2019, 6:30 PM
Rodrigo Oliveira
Rodrigo Oliveira - avatar