+ 1
Please help with my code!
EUR = 1 USD = 0.878030 GBP = 1.16657 RUB = 0.0133329 name = input("What's your name?") print("Hello" + " " + name) euros = input("How many euros do you wish to convert?") chosen_currency = input("What currency do you wish to convert" + euros + " " + "euros into?(USD, RUB, GBP)"): if chosen_currency == USD: print(euros * USD) elif chosen_currency == RUB: print(euros * RUB) elif chosen_currency == GBP: print(euros * GBP) else: print("Sorry, we cannot calculate that!") I just can't get it to work!
17 odpowiedzi
+ 1
You probably want do use '' around USD, RUB and GBP in your if-else part.
Otherwise the user has to enter literally 0.878030 to convert his euros to USD.
+ 1
It says that the line "if chosen_currency == "USD"" is wrong. Like it says that the "if" itself is wrong
+ 1
CR34TUR3.
You have too many mistakes.
Could you post your code for a more detailed explanation?
+ 1
Vasiliy. I posted the original code
+ 1
Debug:
1. EUR = 1
2. USD = 0.878030
3. GBP = 1.16657
4. RUB = 0.0133329
5.
6. name = input("What's your name?")
7. print("Hello" + " " + name)
8.
9. euros = int(input("How many euros do you wish to convert?"))
10. chosen_currency = input("What currency do you wish to convert "+str(euros)+" "+"euros into?(USD, RUB, GBP)")
11. if chosen_currency == "USD":
12. print(euros * USD)
13. elif chosen_currency == "RUB":
14. print(euros * RUB)
15. elif chosen_currency == "GBP":
16. print(euros * GBP)
17. else:
18. print("Sorry, we cannot calculate that!")
+ 1
So it was all because i didn't know how to use "int()"?
+ 1
CR34TUR3.
No, this is only the first mistake.
+ 1
I will go through this thoroughly
+ 1
CR34TUR3.
Good luck!
+ 1
I fixed it the way you did it. Says it must be a str() and not int() and when i switch it to str() it says it cannot multiply str() by float and then i switch to float() and it says must be str() and not float()
It's in the spot where "euros" is defined in your comment
+ 1
CR34TUR3
☺
Isn't it easier to drop the link to the code?
+ 1
CR34TUR3
You fixed only one error out of 10
+ 1
CR34TUR3
But let's sort it out with the reference code. XD?😕
Option 1:
1. Click on the "+" icon;
2. Choose "Insert Code";
3. Find your code.
☺
0
I'm on a mobile phone so no xd
0
I updated my code on my profile(my original code is on my pc on Pycharm)
0
What did i do wrong then? I think i followed your debug message