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
#3
The variable coffee is defined inside the chooseCoffee() function. You can't refer to that variable outside the function. If you want to use information returned from the function you need to assign it to a variable. You could even make that variable coffee, but I'm going to use a different name to show it instead.

mycoffee = chooseCoffee()      # information stored in mycoffee in this section of code
if mycoffee == "iced coffee":  # don't need parenthesis here
    print('Cashier: "Iced coffee it is!"')
cris_ram415 likes this post
Reply


Messages In This Thread
RE: name error with text based rpg code - by bowlofred - Oct-24-2020, 03:46 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Color a table cell based on specific text Creepy 11 2,148 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,132 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,974 Apr-20-2021, 02:26 PM
Last Post: buran
  Winning/Losing Message Error in Text based Game kdr87 2 3,035 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,206 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