Skip to content
Amazon 2.0
Profile icon
MuditMalhotra

the second version of amazon

You are viewing a single comment. View All
Profile icon
OscarSowerbutts

Nice, but if you asked your questions like this:

user_reply = input('''1) Phones \n 2) Cables and Adapters \n 3) Headphones >>> ''')

it would be better.
The triple quotes ''' lets you have more than one line of text (you can push enter) and then you can have the python-style >>> input prompt.

Also the numbers make it confusing: do I type 'Phones' or do I type '1'?

Make it clear at the beginning - I recommend numbers because that eliminates spelling mistakes.
Try to add an invalid input:

import sys if user_reply == '1': #do thing elif user_reply == '2' #do thing else: print('invalid input. please start again') sys.exit('Error message here')

That would at least tell the user what went wrong.

Profile icon
MuditMalhotra

thank you that was really helpful I'll work on it

@OscarSowerbutts

Profile icon
OscarSowerbutts

@MuditMalhotra
you are welcome