Re: Python cannot count apparently

2021-02-08 Thread Michael F. Stemper
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: assign

RE: Python cannot count apparently

2021-02-08 Thread Schachner, Joseph
-Original Message- From: Michael F. Stemper Sent: Monday, February 8, 2021 9:19 AM To: python-list@python.org Subject: Re: Python cannot count apparently On 07/02/2021 13.34, Philipp Daher wrote: > Hello, > > I recently coded this snippet of code: > myString=„hello“ &g

Re: Python cannot count apparently

2021-02-08 Thread Michael F. Stemper
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

Re: Python cannot count apparently

2021-02-07 Thread Peter Pearson
On Sun, 7 Feb 2021 20:49:52 + (UTC), Kevin M. Wilson wrote: > Set i = 0 at the begin of the code, that way each entry starts at > Logical 0 of the array/container/list... No. The original code, as posted, was >>I recently coded this snippet of code: >>myString=„hello“ >>for i in

Re: Python cannot count apparently

2021-02-07 Thread dn via Python-list
On 08/02/2021 09.49, Kevin M. Wilson via Python-list wrote: > Set i = 0 at the begin of the code, that way each entry starts at Logical 0 > of the array/container/list... FYI: https://docs.python.org/3/library/stdtypes.html#typesseq-range See also @Chris' contribution regarding the pythonic idi

Re: Python cannot count apparently

2021-02-07 Thread Kevin M. Wilson via Python-list
Set i = 0 at the begin of the code, that way each entry starts at Logical 0 of the array/container/list... "The only way to have experience is by having the experience"! On Sunday, February 7, 2021, 12:56:40 PM MST, Karsten Hilbert wrote: Am Sun, Feb 07, 2021 at 07:47:03PM + schr

Re: Python cannot count apparently

2021-02-07 Thread Karsten Hilbert
Am Sun, Feb 07, 2021 at 07:47:03PM + schrieb Paul Bryan: > That's not the only problem with the code. There's a missing close- > paren and a reference to "string" which I presume was meant to be > "myString". I know. I wasn't going to spoil everything right away. The sort of response we would

Re: Python cannot count apparently

2021-02-07 Thread Paul Bryan
That's not the only problem with the code. There's a missing close- paren and a reference to "string" which I presume was meant to be "myString". Suggest OP create a reproducible case, and paste the code and output verbatim. On Sun, 2021-02-07 at 20:40 +0100, Karsten Hilbert wrote: > Am Sun, Feb

Re: Python cannot count apparently

2021-02-07 Thread Joel Goldstick
On Sun, Feb 7, 2021 at 2:36 PM Philipp Daher via Python-list 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 > > And SOMETIMES, the o

Re: Python cannot count apparently

2021-02-07 Thread Chris Angelico
On Mon, Feb 8, 2021 at 6:36 AM Philipp Daher via Python-list wrote: > > Hello, > > I recently coded this snippet of code: > myString=„hello“ > for i in range(len(myString): > print(string[i]) This code won't work as is. Please *copy and paste* your code when asking for help. > And now for t

Re: Python cannot count apparently

2021-02-07 Thread Karsten Hilbert
Am Sun, Feb 07, 2021 at 08:34:34PM +0100 schrieb Philipp Daher via Python-list: > I recently coded this snippet of code: > myString=„hello“ I doubt you have (coded *this* snippet of code) -- because those quotes wouldn't work. Karsten -- GPG 40BE 5B0E C98E 1713 AFA6 5BC0 3BEA AC80 7D4F C89B --

Python cannot count apparently

2021-02-07 Thread Philipp Daher via Python-list
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 And SOMETIMES, the output changes to: ohell WHY??? Why do I get different outputs with the EXACT SAME CODE? Can