+ 2

How do I write my age is n years,n is a variable having a value. I am getting errors

16th Jan 2017, 3:25 PM
Akshay
Akshay - avatar
5 odpowiedzi
+ 3
a = 12 b = 30 print("The answer of {} + {} is {}, as anything".format(a,b,a+b))
16th Jan 2017, 4:09 PM
visph
visph - avatar
+ 2
n = 25 print("My age is {} years!".format(n))
16th Jan 2017, 3:29 PM
Etem Hyusnev
Etem Hyusnev - avatar
+ 2
You can use same syntax. You will need to specify order of the variables in format() statement. For example : name = 'John' age = 25 print("Hello. My name is {} and I am {} years old".format(name,age))
16th Jan 2017, 4:06 PM
Etem Hyusnev
Etem Hyusnev - avatar
+ 1
Thank you How can I write if I should use two variables in same print statement?
16th Jan 2017, 3:40 PM
Akshay
Akshay - avatar
0
Please explain for both na. ...I jst started learning python and would like to learn more and more
16th Jan 2017, 7:57 PM
Akshay
Akshay - avatar