How can i secure that error will be presented if answer is something else than 1 to 10 in the first input "nr of cost items to be added" is written? (and promt should go back to "nr of cost items to be added").
message_error = "Not correct input."
num = int(input("Nr of cost items to be added: ") or "3")
for n in range(num):
while True:
try:
cost_items = int(input("Cost per item: "))
break
except ValueError:
print(message_error)
continue