Python Forum
name error with text based rpg code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
name error with text based rpg code
#4
Awesome! Thanks so much! I now have a different problem, however. Even after using a valid input, it repeats the function twice. Here's my updated code:

def chooseCoffee ():
    coffee = ""
    while coffee != "iced coffee" and coffee != "black coffee" and coffee != "cappuccino": # input validation
        coffee = input("Choose your coffee (iced coffee, black coffee, or cappuccino): ")

    return coffee
chooseCoffee()
coffee = chooseCoffee()
if coffee == "iced coffee":
    print('Cashier: "Iced coffee it is!"')
elif coffee == "black coffee":
    print('Cashier: "Black coffee it is!')
elif coffee == "cappuccino":
    print('Cashier: "Cappuccino it is!')
Reply


Messages In This Thread
RE: name error with text based rpg code - by cris_ram415 - Oct-25-2020, 04:53 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Color a table cell based on specific text Creepy 11 2,147 Jul-27-2023, 02:48 PM
Last Post: deanhystad
  select Eof extension files based on text list of filenames with if condition RolanRoll 1 1,561 Apr-04-2022, 09:29 PM
Last Post: Larz60+
  Extracting Specific Lines from text file based on content. jokerfmj 8 3,129 Mar-28-2022, 03:38 PM
Last Post: snippsat
  Extract text based on postion and pattern guddu_12 2 1,680 Sep-27-2021, 08:32 PM
Last Post: guddu_12
  A text-based game [SOLVED] Gameri1 6 3,973 Apr-20-2021, 02:26 PM
Last Post: buran
  Winning/Losing Message Error in Text based Game kdr87 2 3,034 Dec-14-2020, 12:25 AM
Last Post: bowlofred
  cx_Oracle.DatabaseError: Error while trying to retrieve text from error ORA-01804 rajeshparadker 0 8,672 Nov-12-2020, 07:34 PM
Last Post: rajeshparadker
  Split gps files based on time (text splitting) dervast 0 1,913 Nov-09-2020, 09:19 AM
Last Post: dervast
  Extracting data based on specific patterns in a text file K11 1 2,250 Aug-28-2020, 09:00 AM
Last Post: Gribouillis
  Read Multiples Text Files get specific lines based criteria zinho 5 3,204 May-19-2020, 12:30 PM
Last Post: zinho

Forum Jump:

User Panel Messages

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