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

0

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

Mwsdo

3 Answers

New Answer

+3

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: https://code.sololearn.com/c76OnygcB39j/?ref=app

+2

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

0

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