V
V
Vadim kyklaed2015-03-27 13:57:45
Python
Vadim kyklaed, 2015-03-27 13:57:45

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

2 answer(s)
A
Alexander Talalaev, 2015-03-27
@kyklaed

What mistake? Most likely something related to output to a file: whether the file exists, is writable, and so on.

V
Vladimir Martyanov, 2015-03-27
@vilgeforce

The text of the error in the studio!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question