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")

6th May 2023, 2:52 PM
Rainnn
Rainnn - avatar
6 Antworten
+ 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}.")
6th May 2023, 3:46 PM
Per Bratthammar
Per Bratthammar - avatar
+ 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")
6th May 2023, 5:52 PM
Lothar
Lothar - avatar
+ 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...
6th May 2023, 3:22 PM
Ausgrindtube
Ausgrindtube - avatar
+ 3
I solved it! Thanks so much for all the help!!
7th May 2023, 4:54 AM
Rainnn
Rainnn - avatar
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.
6th May 2023, 2:53 PM
Rainnn
Rainnn - avatar
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.
6th May 2023, 2:53 PM
Rainnn
Rainnn - avatar