Why ive got that result in the second code ,and why those numbers were in that order and form | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why ive got that result in the second code ,and why those numbers were in that order and form

https://code.sololearn.com/cAkm9y2z5siD/?ref=app

7th May 2023, 2:15 AM
Sarah
Sarah - avatar
4 Answers
+ 4
Python is great, its awesome! count = 0 P > 0 y > 0 t > 0 h > 0 o > 1 [count + 1; 0+1] n > 1 > 1 i > 2 [count + 1; 1+1] s > 2 > 2 g > 2 r > 2 e > 3 [count + 1; 2+1] a > 4 [count + 1; 3+1] t > 4 , > 4 > 4 i > 5 [count + 1; 4+1] t > 5 s > 5 > 5 a > 6 [count + 1; 5+1] w > 6 e > 7 [count + 1; 6+1] s > 7 o > 8 [count + 1; 7+1] m > 8 e > 9 [count + 1; 8+1] ! > 9
7th May 2023, 5:46 AM
Fꫀⲅძ᥆͟ᥙ᥉᯽
Fꫀⲅძ᥆͟ᥙ᥉᯽ - avatar
+ 7
Sarah , your code uses only one space per indentation level. this reduces the readability of the code. > it is recommended by pep-0008 (python style guide) to use *4 spaces per indentation level*. you can find more information here: https://peps.python.org/pep-0008/#indentation
7th May 2023, 6:30 AM
Lothar
Lothar - avatar
+ 3
because of the indentation the print is considered the part of the for loop so, it's printing it N times.
7th May 2023, 2:39 AM
zexu knub
zexu knub - avatar
+ 2
indentation is semantically significant in python, so if you indent it like that it's part of the for loop and prints count for each letter in the input as it goes along
7th May 2023, 2:35 AM
Orin Cook
Orin Cook - avatar