0

Help me , I don't understand this exercise!

Why this code fail in Argentina practice code? Somebody can help me? values = list(input()) num1 = int(values[0]) num2 = int(values[1]) peso_to_dolar = num1 * 2 / 100 dolar = num2 if peso_to_dolar < dolar : print("Pesos") else: print("Dollars")

17th Jul 2020, 3:12 PM
d3ku07
d3ku07 - avatar
7 ответов
+ 1
Instead using type conversion in input use 2 different input functions, one for dollar and one for pesos. Then do pesos to dollars conversion. Then whole code is same....... Hope it helped
17th Jul 2020, 4:06 PM
Sanjyot21
Sanjyot21 - avatar
0
The problem is on the first 3 lines of code. If you enter a single number like 15 there will be no problem (This number is actually treated as a string, and it's digits will act in the programme as two numbers), but you cannot expect to get numbers with more than one digit to operate with. Also, if the User enters something like (1, 17.45, 35.0) the programme could not convert he was 2nd element into an integer, 'cause that element would be a string *Remember that the interpreter takes any input as a string*, and there would be a ValueError. The int function cannot either convert other punctuations or spaces. So, the whole thing depends on what the User enters. I hope this explanation's helped you, guy.
17th Jul 2020, 4:58 PM
Joseph
Joseph - avatar
0
When I wrote "he was" I meant "the", sorry
17th Jul 2020, 5:01 PM
Joseph
Joseph - avatar
0
I totally agree with Sanjyot 🖒
17th Jul 2020, 5:07 PM
Joseph
Joseph - avatar
0
Thank you guys
17th Jul 2020, 6:11 PM
d3ku07
d3ku07 - avatar
0
print ('You're welcome')
17th Jul 2020, 6:24 PM
Joseph
Joseph - avatar
0
print("Thank You My friend")
17th Jul 2020, 6:32 PM
d3ku07
d3ku07 - avatar