Python cannot count apparently

Michael F. Stemper mstemper at gmail.com
Mon Feb 8 09:18:41 EST 2021


On 07/02/2021 13.34, Philipp Daher wrote:
> Hello,
> 
> I recently coded this snippet of code:
> myString=„hello“
> for i in range(len(myString):
>       print(string[i])
> 
> And now for the weird part:
> 
> SOMETIMES, the output is this:
> 
> hello

Strange. When I fix the errors in what you posted:
- wrong character to start the string
- wrong variable name in the call to print()

I get[1]:


... myString="hello"
... for i in range(len(myString)):
...   print( myString[i] )
...
h
e
l
l
o
...

You must have done something to suppress the newlines after
each call to print().

So it's quite obvious that the code you posted has very little
to do with the code you ran. If you really want us to help, please
directly copy and paste the exact code that you ran. We can't
really help you with only guesses as to what you did.



[1] (leading > replaced with . to fool news clients)
-- 
Michael F. Stemper
Galatians 3:28


More information about the Python-list mailing list