+ 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)
4 ответов
+ 4
Try n=len(shopping_cart)
https://code.sololearn.com/cw612TjzBG9U/?ref=app
+ 3
You aren't assigning list length like this ,
len(shopping_cart)
+ 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.
+ 1
Thank you all for clarifying my doubt.