+ 2
I don't understand the 3rd and 5th line of this code, can someone help me out please?
words = input() inpt = words.split(" ") a = [] for i in inpt: a.append(len(i)) num = max(a) for j in inpt: if num == len(j): print(j)
4 odpowiedzi
+ 3
3rd line: a=[]
Here we are taking an empty list
5th line: a.append(len(i))
Here we are adding the length of i in the list (a).
+ 1
Are we adding the length of I to the list? .What's the use of the "append"?
+ 1
append is used to add the specific element in that list, you can refer to the links:
edit]: oops, I didn't answered your first question, yes we are adding the length of the i in the list (length of input).
https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/ref_list_append.asp
+ 1
Thank you ㅤㅤㅤ