0
Challenge Problem with len Method
a=str(‘2‘*3**2) print(len(a)) Why is it 9 please ? a should contain 8 items? Is there a way to Look up for explanations if you answer a challenge question wrong? The right answer only is Not enough sometimes Thanks in advance.
4 Respostas
+ 5
3**2 is 9 cuz ** means exponent|empower
and then it will multiply "2" 9 times
so in the end you will have string 222222222 and lenght of it is 9
0
Lol didnt even know 3**2 means 3*3.
what happens to the string '2' when 3**2=9 is executed? it seems it doesnt have any effect on the result.
sorry for those noob questions
0
started to learn python months ago and can‘t remember what len excactly does.
thought it would count the items in a variable/list
0
Thanks budd