Letter replacer - suggestions?

Chris Angelico rosuav at gmail.com
Mon Dec 7 14:54:45 EST 2020


On Tue, Dec 8, 2020 at 6:51 AM Schachner, Joseph
<Joseph.Schachner at teledyne.com> wrote:
>
> The only comment I have is that you didn't check the inputs at all.  Suppose the word I type in is "1234".   1234 will turn into an int, not a string.
> You can't index through an int, it's one thing.  So the program will probably throw an error.

Not sure what you mean here. The input() function always returns a
string, even if it's nothing but decimal digits.

(If you're using an ancient version of Python, then it will evaluate
the input, which would mean digits turn into an integer, but other
things will just error out - they won't be strings. Also, all the
f-strings in the OP's code wouldn't work, so that's irrelevant here.)

ChrisA


More information about the Python-list mailing list