Python with csv (can anyone say the error in this) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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()

9th Oct 2022, 1:53 PM
NITHIVARSHA TP
2 Answers
0
when you try searching for a player in CSV I think it's problematic loop
9th Oct 2022, 2:55 PM
Daljeet Singh
Daljeet Singh - avatar
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.
10th Oct 2022, 12:40 AM
Emerson Prado
Emerson Prado - avatar