+ 2

How to assign list length to new variable?

shopping_cart = ['eggs', 'grapes', 'mango', 'bread', 'butter', 'rice', 'soup', 'meat', 'beans'] 1. Create a variable called n and assign the length of your shopping_cart list to it. I tried as below but my test case failed not sure why? n=shopping_cart print(n)

17th Sep 2020, 6:14 PM
Abhi
Abhi - avatar
4 Respostas
17th Sep 2020, 6:17 PM
Bartika🎶
Bartika🎶 - avatar
+ 3
You aren't assigning list length like this , len(shopping_cart)
17th Sep 2020, 6:17 PM
Abhay
Abhay - avatar
+ 2
n=len(shopping_cart) This is covered in the Python tutorial so, if you haven't reached that part yet, you should continue with it before concentrating on problems.
17th Sep 2020, 6:18 PM
Russ
Russ - avatar
+ 1
Thank you all for clarifying my doubt.
17th Sep 2020, 6:28 PM
Abhi
Abhi - avatar