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)
10 Antworten
+ 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.
+ 4
You can do it without formatting like this:
print(Name + ' is ' + Age + ' years old.')
Notice the spaces inside the quotation marks.
+ 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 đâșïžâșïž
+ 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 :)
0
you don't put spaces between words
0
Vasiliy is this correct ?
Print(ânameâ+âisâ+âageâ+âyears oldâ)
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 â„ïž
0
Simon Sauter thankyou ! I think this insight about correct spacing is what i was missing! Very helpful
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.
0
you can use only single or double quotes.
Name = "james"
Age = "42"
print(Name+" is "+Age+" years old")