Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the difference.
#1
Having a problem I can't understand. I can print one global string but not another.

#Playfair ENDE

LETTERS = 'ABCDEFGHIKLMNOPQRSTUVWXYZ'
MESSAGE = '''Oh, I see you ate one too!'''

def main():
    print (LETTERS)
    print (MESSAGE)
    MESSAGE = '''Oh no I didn't'''
    print (MESSAGE)




if __name__ == '__main__':
    main()
When I run it I get :
Error:
ABCDEFGHIKLMNOPQRSTUVWXYZ Traceback (most recent call last): File "C:\Users\jarrod0987\AppData\Local\Programs\Python\Python36-32\Stub.py", line 16, in <module> main() File "C:\Users\jarrod0987\AppData\Local\Programs\Python\Python36-32\Stub.py", line 8, in main print (MESSAGE) UnboundLocalError: local variable 'MESSAGE' referenced before assignment
Why does LETTERS print but MESSAGE not print?
Reply


Messages In This Thread
What is the difference. - by jarrod0987 - Apr-11-2018, 04:44 AM
RE: What is the difference. - by buran - Apr-11-2018, 05:26 AM
RE: What is the difference. - by jarrod0987 - Apr-11-2018, 05:32 AM
RE: What is the difference. - by buran - Apr-11-2018, 06:22 AM
RE: What is the difference. - by jarrod0987 - Apr-11-2018, 06:54 AM

Forum Jump:

User Panel Messages

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