Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie needs help part 2
#7
Agree with Lars that dictionary is more the way to go. Here is a version without error checking but otherwise works.
cars = {
    'audi':"you picked Audi",
    'volkswagon':"you picked volkswagon",
    'volvo':"you picked volvo"
}

while True:
    choice = input('Enter chosen model ').lower()
    if choice == "exit":
        break
    print(cars[choice])
Reply


Messages In This Thread
Newbie needs help part 2 - by dvejsa - Sep-07-2022, 07:17 PM
RE: Newbie needs help part 2 - by deanhystad - Sep-07-2022, 08:00 PM
RE: Newbie needs help part 2 - by dvejsa - Sep-08-2022, 09:15 AM
RE: Newbie needs help part 2 - by deanhystad - Sep-08-2022, 01:52 PM
RE: Newbie needs help part 2 - by Larz60+ - Sep-07-2022, 08:01 PM
RE: Newbie needs help part 2 - by XavierPlatinum - Sep-07-2022, 08:10 PM
RE: Newbie needs help part 2 - by dvejsa - Sep-08-2022, 09:14 AM
RE: Newbie needs help part 2 - by jefsummers - Sep-08-2022, 11:55 AM
RE: Newbie needs help part 2 - by Larz60+ - Sep-08-2022, 02:23 PM
RE: Newbie needs help part 2 - by deanhystad - Sep-08-2022, 08:39 PM
RE: Newbie needs help part 2 - by Larz60+ - Sep-09-2022, 10:16 AM
RE: Newbie needs help part 2 - by jefsummers - Sep-09-2022, 07:38 PM
RE: Newbie needs help part 2 - by Yoriz - Sep-10-2022, 12:02 AM
RE: Newbie needs help part 2 - by deanhystad - Sep-09-2022, 08:16 PM
RE: Newbie needs help part 2 - by jefsummers - Sep-10-2022, 08:55 PM

Forum Jump:

User Panel Messages

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