How to add space in begginer python | Sololearn: Learn to code for FREE!


How to add space in begginer python

I want to do a challenge for beginner python course and one of the challenges is to print a name and age name= "John" age= "24" print (name + 'is' + age 'years old') and the output is: Johnis24years old how can i add space between john , is , 24 and years?

4/25/2021 9:43:57 PM


3 Answers

New Answer


1. You can add commas print(name, "is", age, "years old") 2. using f-string print(f"{name} is {age} years old") 3. using the sep argument print(name, "is", age, "years old", sep=" "*4) More info:


use 2 spaces before and after " is " and 1 space before " years." Like this print(name+" is "+age+" years")


Use the space in double quote like ...+ " is " + ...+ " years old " And, If you need to make new line, use this: print("\n")