0
String formating Inserting spaces
Can someone help me insert spaces, please....(the output is Nameisageyears old?)i/o Name is age years old... name = input() age = int(input()) #your code goes here print("{0}{1}{2}{3}".format(name ,"is", age ,"years old"))
4 Answers
+ 1
# if you want to insert spaces, better use fstrings:
print(f'{name} is {age} yo')
# or your way:
print('{0} is {1} yo'.format(name,age))
# or ...:
print('%s is %d yo'%(name,age))
0
What have you tried?
Does your "is" output all the characters between the quotation marks? What if you changed that to "is or is not"? Would all of the characters be printed (including the spaces)?
0
You got it right just keep the name and age as format and keep {0} and {1} add a space between the 0 and 1 and put is. Then at the end of {1} add another space then years old
0
Thank you for all the feedback...it worked!
name = input()
age = int(input())
#your code goes here
a="{} is {} years old".format(name,age)
print(a)