I've written a Python script (work.py) and it's running well in Windows, but when I run it on Ubuntu, it shows me an error, if I enter the name as a string, but if I enter the name as an integer it's running fine.
NameError:
thanapong@thanapong-Lenovo-C360:~/Desktop$ python work.py
Hours: 72
Minutes: 0
Seconds: 0
Enter the name: CHATCHAI
Traceback (most recent call last):
File "work.py", line 9, in <module>
look for = str(input("Enter the name: "))
File "<string>", line 1, in <module>
NameError: name 'CHATCHAI' is not defined
thanapong@thanapong-Lenovo-C360:~/Desktop$ python work.py
Hours: 72
Minutes: 0
Seconds: 0
Enter the name: BILLY
Traceback (most recent call last):
File "work.py", line 9, in <module>
look for = input("Enter the name: ")
File "<string>", line 1, in <module>
NameError: name 'BILLY' is not defined
With int it works fine:
thanapong@thanapong-Lenovo-C360:~/Desktop$ python work.py
Hours: 72
Minutes: 0
Seconds: 0
Enter the name: 2
3
0
Not found
1
2
3
4
0
Not found
1
2
3
4
0
Not found
1
2
This is my code.
import pandas as pd
import time
hourz=input('Hours: ')
minz=input('Minutes: ')
secz=input('Seconds: ')
lookfor = input("Enter the name: ")
name = str(lookfor)
x = 5
print(' ')
hour=int(hourz)
min=int(minz)
sec=int(secz)
day = int(((hour*60*60)+(min*60)+(sec))/86400)
print(day)
for b in range(day):
for a in range(x):
time.sleep(1)
print(a)
if a == 0:
data = pd.read_csv("/media/thanapong/F91B-8B18/Customer_List.txt", header=0)
query = data.loc[data['NAME']==name]
if not query.empty:
print(query)
data.loc[data['NAME']==name, 'SCORE'] = (query.SCORE - 1)
print()
print(data.loc[data['NAME']==name])
data.to_csv("/media/thanapong/F91B-8B18/Customer_List.txt", index=None)
else:
print('Not found')
print(' ')
print(' ')
print("End")
This is example of Customer_List.txt (it has many lines).
ID,NAME,LASTNAME,SCORE,TEL,PASS
61070500216,CHATCHAI,KARUNA,22,123456789,12345
61070500217,BIGM,KORATBOY,15,123456789,123456789
raw_input()
I think. Perhaps your default python on Windows is python3? See for example Python Input and Output