If the User Input in mark() funtion is string not integer the list.txt content will delete and if it's true also it will delete the content then after i want to return to main() funtion
Example:
Enter a number to mark: g
Invalid Input!//the list.txt file content here was deleted
Enter a number to mark: 2 //true but the content of the list.txt was deleted also
and Return to the Main if true
How to fix this Error?
def mark(pick):
pick = fileName
flag = open(pick, "w")
while True:
choice = input("Enter number to mark: ")
if choice == True:
return True
break
list[int(choice)] = list[int(choice)].replace('"N"', '"Y"')
for line in list:
flag.write(line)
try:
val = int(choice)
return val
except ValueError:
print("Invalid Input")
return choice
print(list[int(choice)]," has been mark as visited")