Last active
April 27, 2021 02:18
-
-
Save herikwebb/e481b40c9ed6465ad1082d9c33dc76c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def write_to_file(filename, grades): | |
with open(filename, 'w') as f: | |
for v in grades.values(): | |
if isinstance(v, list): | |
blah = ' '.join(str(z) for z in v) | |
f.write(blah + '\n') | |
else: | |
f.write(str(v) + '\n') | |
grades = {'Name': 'George Mason', 'Projects': [100.0, 100.0, 95.0, 100.0, 100.0, 95.0], 'Homeworks': [100.0, 100.0, 90.0, 100.0, 100.0, 100.0], 'zyBooks': [100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 90.0], 'Quizzes': [90.0, 100.0, 100.0, 100.0, 100.0, 100.0, 100.0, 90.0, 90.0], 'Midterm': 95.0, 'Final': 100.0} | |
filename = "C:\\Users\\herik\\git\\blah\\writetofile.grades" | |
write_to_file(filename, grades) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment