+ 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?

13th Nov 2022, 5:17 PM
Honest Thomas
Honest Thomas - avatar
3 Respostas
+ 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")
13th Nov 2022, 5:51 PM
Ausgrindtube
Ausgrindtube - avatar
+ 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...
13th Nov 2022, 6:29 PM
Jayakrishna 🇮🇳
0
Bless you!
13th Nov 2022, 6:19 PM
Honest Thomas
Honest Thomas - avatar