0

How to make var. Equal to rest of other two(Python)

hello everyone. i have a little dilema here and i don't find the way to solve it. i wanna make a kind of a "exchange calculator" and i am trying to make a var. equal to the rest of other two, but when i run the program i got an error, saying that you can't rest 'nonetype' with 'nonetype'. i will let the code here and try by yourselves https://code.sololearn.com/cgUu9c8G9oYl/?ref=app

1st Apr 2018, 2:08 AM
Javier Rivero
Javier Rivero - avatar
2 Respostas
+ 4
First of all, Why the hell will you ever write a code like that? Writing x= print(input()) will make it equal to nothing. you're basically doing. print(input()). i suggest doing it like this. x=input() print(x) y=input() print(y) and second of all, input is a string. meaning you have to declare it as an integer. x= int(input()) if you want it to act as an integer instead of a string. and this is the code you should use: x=int(input()) print(x) y=int(input()) print(y) z=x-y print(z)
1st Apr 2018, 2:14 AM
Tomer Sim
Tomer Sim - avatar
- 1
thank you very much for your help! now i have fixed it and it works as i wanted. it is a very easy calculation but i wanted to practice with something easy firstly. this is the code: product=int(input()) print(product) mount=int(input()) print(mount) change=(mount-product) print(change) if change==0: print("correct") elif change>0: print(change) else: print("denied. need more cash to pay")
1st Apr 2018, 2:39 AM
Javier Rivero
Javier Rivero - avatar