Код: Выделить всё
try:
with open("numbers.txt", 'r') as file:
numbers = [int(line.strip()) for line in file]
except FileNotFoundError:
print(f"Error: The file '{numbers.txt}' was not found.")
return
except ValueError:
print("Error: The file contains non-integer values.")
return
Код: Выделить всё
150
300
220
180
210
190
Подробнее здесь: https://stackoverflow.com/questions/792 ... valueerror
Мобильная версия