+ 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.
3 odpowiedzi
+ 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.")
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.