+ 1
A program that retrieves information with Python
Say I'm making a program for a travel agency, like a customer service bot. I give the user a list of things the customer would like assistance with and I give them some options like: Current deals press 1, Cancellation Options? Press 2 ! I would just make a simple input output program right? But the tricky part I will not be able to handle is when the options are given how do I make sub options? Like after they pick the first option, that's a section, now it's time to pick from that section. Do I need lists for that?
3 Antworten
+ 2
You could create different classes/methods for each suboption.
Using your example, here's some pseudocode:
Switch(useroption):
Case 1:
caseOneMethod()
Case 2:
caseTwoMethod()
Default:
print("Choose from the above options")
+ 1
You could use nested if-else blocks simply..
Menu :
input1
if input1 :
Sub menu :
if input11
#do
else:
#do
elif input2 :
Sub menu :
if input21
#do
else:
#do
If not understood, then it is better to show your question with code sample what you know then what you are looking like..!
If there many options then, in that case switch works better but python has no switch support until recently, added as match block => match( case) : syntax but still sololearn not updated to. Not supports still.
Hope it helps...
0
Bless you!