On 08/02/2021 13.12, Schachner, Joseph wrote:
This code works:
mystr = "hello"
for ch in mystr:
print(ch, end="")
result is: hello
Note that the for loop does not use range. Strings are iterable, that is they
support Python's iteration protocol. So, for ch in mystr: assigns one
character from mystr to ch each time, each iteration gets the next character.
To prevent each character from appearing on a separate line (in Python 3) you need
end="". That is, don't put in the usual end-of-line ending.
Then you agree that the OP:
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.
--
Michael F. Stemper
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too dark to read.
--
https://mail.python.org/mailman/listinfo/python-list