+ 1

PY String to Int

While following exercise from a book, iv encountered an error in the playground. https://code.sololearn.com/ck4RglyiuEa5/?ref=app The new_age formula is suppose to be able to turn a string into an int and i keep getting an error. I understand that there are other ways to achieve the desired result but thats not what im going for here Is this a bug/oversight or is this intentional.

10th Jul 2020, 5:03 AM
Marie
2 ответов
+ 3
How to fix TypeError? Instead of print("Your dog " + dog_name + " is " + new_age+ " in human years.") , change it to print("Your dog " + dog_name + " is " + str(new_age) + " in human years.") , or fancier method using formatted string literals (Python >= 3.6) print(f"Your dog {dog_name} is {new_age} in human years.")
10th Jul 2020, 5:13 AM
Esch
Esch - avatar
0
The error is when i try to turn the string into an int. My apologies if i didnt make that clear. Edit: I made the changes and it works now :) Thank you for your help.
10th Jul 2020, 5:16 AM
Marie