Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculator python3
#4
(Jan-27-2020, 08:53 AM)ThiefOfTime Wrote: @perfringo actually it is not only the comparison of the while-loop causing the error, but the conversion to int.

Yes, you are correct and I made a mistake.

To catch more typing/error variations ('STOP', 'STop', etc) it is usually good to lower input.

input('Number: ').lower()
With Python 3.8 one can take advantage of walrus operator (no need to assign answer outside the loop):

while (answer := input('Number: ').lower()) != 'stop':
    # do stuff
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
Calculator python3 - by Magicamtt455 - Jan-27-2020, 01:23 AM
RE: Calculator python3 - by perfringo - Jan-27-2020, 08:46 AM
RE: Calculator python3 - by ThiefOfTime - Jan-27-2020, 08:53 AM
RE: Calculator python3 - by perfringo - Jan-27-2020, 10:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Gnuradio python3 is not compatible python3 xmlrpc library How Can I Fix İt ? muratoznnnn 3 4,928 Nov-07-2019, 05:47 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020