I am so stuck at the practice test output: (james is 42 years old) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I am so stuck at the practice test output: (james is 42 years old)

I have tried everything can’t get past it. Name = “james” Age = “42” Need advice I tried the following: Print(“Name” + “is” + “age” + “years old”) Print(Name, + “is” + Age, + “years old”) I don’t even remember other things i kept trying but the closest i got to was output (Jamesis 42 years old)

28th Aug 2021, 7:53 PM
Here.To.Learn
10 Answers
+ 6
Try print(f"{Name} is {Age} years old") The f means that it's a format string, and you can put variables inside the curly braces, and it will output the value of the variables.
28th Aug 2021, 8:59 PM
Chloe
Chloe - avatar
+ 4
You can do it without formatting like this: print(Name + ' is ' + Age + ' years old.') Notice the spaces inside the quotation marks.
28th Aug 2021, 9:19 PM
Simon Sauter
Simon Sauter - avatar
+ 3
Jamal Game George Mathew JOHNNY BOSCO Ejeh Joseph Simon Emeka C. Acorpseinprogress thankyou so much you guys are too kind and like some of you said my error was in spacing and correct use of + . I finally got it right 🙏☺️☺️
30th Aug 2021, 7:55 PM
Here.To.Learn
+ 2
Here.To.Learn if you ever have any other questions I'd be happy to help(if I can) in dms, so offer is always open :)
28th Aug 2021, 9:24 PM
Chloe
Chloe - avatar
0
you don't put spaces between words
28th Aug 2021, 8:08 PM
Solo
Solo - avatar
0
Vasiliy is this correct ? Print(“name”+”is”+”age”+”years old”)
28th Aug 2021, 8:12 PM
Here.To.Learn
0
➵Chloe[she/her] [DMs Open] thanks alot this worked ! Iam not familiar woth the Format string yet maybe the practice test came up way too early in the course thanks alot for helping ♥️
28th Aug 2021, 9:09 PM
Here.To.Learn
0
Simon Sauter thankyou ! I think this insight about correct spacing is what i was missing! Very helpful
28th Aug 2021, 9:43 PM
Here.To.Learn
0
I think where you error is, is from your spacing between the quotation I think one of this can help you out. Print (f" {Name} + is + {Age} + years old ") Or Print (Name + " is " + Age + " years old ") I think one of this can help you out. It's nice you learn something out if your profession I love and this is one of the best things you can do. # Don't quote me wrong.
29th Aug 2021, 4:19 PM
JOHNNY BOSCO
JOHNNY BOSCO - avatar
0
you can use only single or double quotes. Name = "james" Age = "42" print(Name+" is "+Age+" years old")
30th Aug 2021, 12:15 PM
Jamal Game
Jamal Game - avatar