0
Python with csv (can anyone say the error in this)
import csv with open('c:\pyprg\player.csv','w') as f: w = csv.writer(f) n=1 while (n<=10): name = input("Player Name?:" ) score = int(input("Score: ")) w.writerow([name,score]) n+=1 print("Player File created") f.close() searchname=input("Enter the name to be searched ") f=open('c:\\pyprg\\player.csv','r') reader =csv.reader(f) lst=[] for row in reader: lst.append(row) q=0 for row in lst: if searchname in row: print(row) q+=1 if(q==0): print("string not found") f.close()
2 ответов
0
when you try searching for a player in CSV I think it's problematic loop
0
1. Pls put your code in Code Playground, save as public, and add a link to it in the question description. This allows us to test your code and possible solutions.
2. Describe the code objective in the question description. This allows us to know what's wrong in the results.
3. Use consistent indentation. Python style indicates 4 spaces per level.