+ 2
Why ive got that result in the second code ,and why those numbers were in that order and form
4 Respostas
+ 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
+ 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
+ 3
because of the indentation the print is considered the part of the for loop so, it's printing it N times.
+ 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