Pycharm not reading code Correctly

#Parking Ticket machine
Money = 50

import time
print('''
----------------------------
|Press Enter To Continue |
| |
| |
| |
| |
| Made by Ben|
----------------------------
''')
input("")
print('''
----------------------------
|How Long Are you Staying? |
| 1 = 1 hour £1.20 |
| 2 = 2 hours £2.40 |
| 3 = 3 hours £3.00 |
| 4 = All Day £7.00 |
| 5 = All week £14.00|
----------------------------
''')
In = input(">")
if In == "1":
Payment = '1.20'
print("Hello")

if In == "2":
Payment = '2.40'

if In == "3":
Payment = '3.00'

if In == "4":
Payment = '7.00'

if In == "5":
Payment = "14.00"
print(Payment)
print(f"Your current statement is £{Money}")



Error:
Traceback (most recent call last):
File "C:/Users/bcola/Desktop/Other/python/Parking_machine.py", line 42, in <module>
print(Payment)
NameError: name 'Payment' is not defined

Help



1 comment
Comment actions Permalink

Hi,

I've narrowed down the issue to a possible bug and reported it here: https://youtrack.jetbrains.com/issue/PY-34378

Please follow.

The workaround would be to ensure the cursor is always in the last line when you make the input. Also, you would probably want to implement a case when input is not one of the expected values, to avoid NameError

0

Please sign in to leave a comment.