+ 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!

28th Feb 2019, 10:17 AM
Ville Nordström
Ville Nordström - avatar
17 Respuestas
+ 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.
28th Feb 2019, 10:31 AM
merkrafter
+ 1
It says that the line "if chosen_currency == "USD"" is wrong. Like it says that the "if" itself is wrong
28th Feb 2019, 10:40 AM
Ville Nordström
Ville Nordström - avatar
+ 1
CR34TUR3. You have too many mistakes. Could you post your code for a more detailed explanation?
28th Feb 2019, 11:50 AM
Solo
Solo - avatar
+ 1
Vasiliy. I posted the original code
28th Feb 2019, 11:54 AM
Ville Nordström
Ville Nordström - avatar
+ 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!")
28th Feb 2019, 12:10 PM
Solo
Solo - avatar
+ 1
So it was all because i didn't know how to use "int()"?
28th Feb 2019, 12:14 PM
Ville Nordström
Ville Nordström - avatar
+ 1
CR34TUR3. No, this is only the first mistake.
28th Feb 2019, 12:28 PM
Solo
Solo - avatar
+ 1
I will go through this thoroughly
28th Feb 2019, 12:29 PM
Ville Nordström
Ville Nordström - avatar
+ 1
CR34TUR3. Good luck!
28th Feb 2019, 12:39 PM
Solo
Solo - avatar
+ 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
28th Feb 2019, 12:47 PM
Ville Nordström
Ville Nordström - avatar
+ 1
CR34TUR3 ☺ Isn't it easier to drop the link to the code?
28th Feb 2019, 1:05 PM
Solo
Solo - avatar
+ 1
CR34TUR3 You fixed only one error out of 10
28th Feb 2019, 2:16 PM
Solo
Solo - avatar
+ 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. ☺
28th Feb 2019, 2:35 PM
Solo
Solo - avatar
0
I'm on a mobile phone so no xd
28th Feb 2019, 1:06 PM
Ville Nordström
Ville Nordström - avatar
0
I updated my code on my profile(my original code is on my pc on Pycharm)
28th Feb 2019, 1:15 PM
Ville Nordström
Ville Nordström - avatar
0
What did i do wrong then? I think i followed your debug message
28th Feb 2019, 2:26 PM
Ville Nordström
Ville Nordström - avatar