0
pi@raspberrypi:~ $ cd Documents/attendance/
pi@raspberrypi:~/Documents/attendance $ ./Attendance.py 
Please swipe your card: %CHEND151?
Traceback (most recent call last):
  File "./Attendance.py", line 15, in <module>
    eqid = input('Please swipe your card: ').strip().upper()
  File "<string>", line 1
    %CHEND151?
    ^
SyntaxError: invalid syntax
pi@raspberrypi:~/Documents/attendance $ 

I don't understand why I am getting this error? is it because of the % because I try without it and it still happens.

pi@raspberrypi:~/Documents/attendance $ ./Attendance.py 
Please swipe your card: chend151
Traceback (most recent call last):
  File "./Attendance.py", line 15, in <module>
    eqid = input('Please swipe your card: ').strip().upper()
  File "<string>", line 1, in <module>
NameError: name 'chend151' is not defined
pi@raspberrypi:~/Documents/attendance $ 
Sirsyorrz
  • 45
  • 6
  • 5
    You're probably using Python 2 in which case you need to use `raw_input()` rather than `input()`. – Christian Dean Aug 10 '17 at 12:24
  • 3
    Possible duplicate of [input() error - NameError: name '...' is not defined](https://stackoverflow.com/questions/21122540/input-error-nameerror-name-is-not-defined) – fredtantini Aug 10 '17 at 12:24
  • @ChristianDean ahh yes that works, thank you :D, how would I make it run using python 3? would I have to change the `#!/usr/bin/python` part? – Sirsyorrz Aug 10 '17 at 12:27
  • @Sirsyorrz Honestly I'm not 100% sure because I'm not very familiar with Linux shebangs. I guess you would need to change it to `#!/usr/bin/python3` to use Python 3? – Christian Dean Aug 10 '17 at 12:28
  • 1
    A python3 shebang should work as long as Python 3 is installed – khelwood Aug 10 '17 at 12:37

0 Answers0