Jul-22-2017, 04:33 PM
I am trying to work with a file but getting but I am unable to get it working correctly.
I created the following programme:
Sandys-MBP:~ sandycaskie$ python writefile.py
Enter a grade (q to quit):
100
Enter a grade (q to quit):
90
Enter a grade (q to quit):
80
Enter a grade (q to quit):
q
Sandys-MBP:~ sandycaskie$ type grades.txt
-bash: type: grades.txt: not found
Sandys-MBP:~ sandycaskie$
I created the following programme:
outFile = open('grades.txt','w') grade = 0 print("Enter a grade (q to quit):") grade = raw_input() while (grade != 'q'): outFile.write(grade + '\n') print("Enter a grade (q to quit):") grade = raw_input() outFile.close()The command prompt:
Sandys-MBP:~ sandycaskie$ python writefile.py
Enter a grade (q to quit):
100
Enter a grade (q to quit):
90
Enter a grade (q to quit):
80
Enter a grade (q to quit):
q
Sandys-MBP:~ sandycaskie$ type grades.txt
-bash: type: grades.txt: not found
Sandys-MBP:~ sandycaskie$