Python File Handling | Read, Write, Readlines() with Example'

preview_player
Показать описание
Python File Handling | Read, Write, Readlines() with Example"

#PythonFileHandling
#Python
#PythonTutorial
#FileReadWrite
#PythonProgramming
#LearnPython
#PythonCoding
#PythonTips
#CodeWithinstagram
#ReadlinesInPython
#PythonWriteFile
#PythonReadFile
#pythonenglish
#Pythontutorialforbeginners
Рекомендации по теме
Комментарии
Автор

import random

def game():
print("You are playing the game...")
score = random.randint(1, 62)
with open("hiscore.txt") as f:
hiscore = f.read()
if hiscore != "":
hiscore = int(hiscore)
else:
hiscore = 0

print(f"Your score: {score}")
if score > hiscore:
with open("hiscore.txt", "w") as f:
f.write(str(score))

return score

game()

AICHIPE
visit shbcf.ru