0

How many 5's?

How many 5's are printed? x=0 for i in range(1,4) x += i print("5" *x) Output: 10 So, ten fives are printed. I thought we did not count the last number in the range? So shouldn't the output be 6? Thanks to anyone who could provide assistance.

18th Apr 2019, 2:03 AM
tristach605
tristach605 - avatar
1 Respuesta
+ 3
First run I = 1 X = 1 Print 1 5s 2nd run I = 2 X = 3 Print 3 5s 3rd run I=3 X=6 Print 6 5s So 10 fives are printed.
18th Apr 2019, 2:23 AM
Sam Stoltenberg
Sam Stoltenberg - avatar