0
Hii can someone help me with the Neverland coding challenge pls?
a=int(input()) b=int(input()) x=a+b print("My twin is x years old and they are b years older than me")
6 Answers
+ 10
# Hi, Rainnn !
# Youâre talking about formating for input and output, but have you consider f-string formating? Iâm sure it would suit your case. Example:
a = int(input() or 10)
b = 2 * a
print(f"If you double {a} you get {b}.")
+ 7
Rainnn ,
the preferred way to do this output is to use a f-string as Per Bratthammar mentioned.
but we can also do it by using the comma notation, no need to juggle with spaces or convert numbers to strings:
...
print("My twin is", x, "years old and they are", b, "years older than me")
+ 6
Your problem is that you are trying to add integers into a print statement where you've declared a string using "".
Have you heard about concatenation? See if that helps.
Another option, would be to change the integers into strings...
+ 3
I solved it! Thanks so much for all the help!!
0
If you live in Neverland, you never get any older! You and your twin go to Neverland for an afternoon, then your twin goes back home and you stay. Over time, how much older is your twin than you, and how old are they?
Task:
Evaluate the difference between your ages, and the age that your twin is now if you are given the age that you were when you got to Neverland, and the time that has elapsed since then.
0
Input Format:
Two integer values. The first represents your age when you arrived at Neverland, and the second, the number of years that have passed since your twin went back.
Output Format:
A string that states 'My twin is X years old and they are Y years older than me' Where X is their age and Y is the difference.