Thank you both - brilliantly explained and actually made a lot of sense :)
I am starting (slowly) to get my head around coding, and you patience is appreciated.
On this the last statement, there is an error I believe as "first, second" is not defined?
I solved the problem myself with some trial and error :)
It passes the pep8 approval too ;) Getting better for a newbie.
I am starting (slowly) to get my head around coding, and you patience is appreciated.
On this the last statement, there is an error I believe as "first, second" is not defined?
first, second = validate('Enter first number: '), validate('Enter second number: ') op = operation(f"Enter operation (one from: {', '.join(ops.keys())}): ") # ensures that only defined operators are listed print(f'Answer is {op(first, second)}')
I solved the problem myself with some trial and error :)
It passes the pep8 approval too ;) Getting better for a newbie.
first = validate('Enter first number: ') op = operation(f"Enter operation (one from: {', '.join(ops.keys())}): ") second = validate('Enter second number: ') print(f'Answer is {op(first, second)}')