Answer the question
In order to leave comments, you need to log in
An error in the code, the function is not processed, how to fix it?
Help me find an error or explain;) I sit and I can’t understand, the error shows me in the line the file_calculation.write (r_addition)
problem of course may be due to the fact that when calling the function I use 2 values, and in the function itself when adding I use 3 values.
pastie.org/10057112
FILE_NAME = 'data.txt'
def input_value (type_value, message, message_error):
while True:
try:
return type_value(input(message))
except (TypeError, ValueError):
print(message_error)
def calculating_saving_result (r_digit, r_digit2):
file_calculation = open (FILE_NAME, 'a')
if value==1:
r_addition = r_digit + r_digit2
file_calculation.write (r_addition)
file_calculation.close()
value = input_value(int,"number of action","message_error")
digit = input_value(float,"enter the first number","message_error")
digit2 = input_value(float, "Enter the second number: ", "message_error2")
calculating_saving_result (digit,digit2)
Answer the question
In order to leave comments, you need to log in
What mistake? Most likely something related to output to a file: whether the file exists, is writable, and so on.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question