+ 1
Iām new and canāt figure out why I canāt print spaces
name = "James" age = "42" print ((name + "is")+ (age + "years old")) The solution(sorry Iām still learning terms) is Jamesis42years old I googled spaces and have tried āā and a couple other things but it still wonāt run Thanks
4 Answers
+ 3
You have to actually put a space inside the quotation marks. E.g. to print a single space use
" "
+ 2
you could also use formatted strings, in order to print what you are trying to print with spaces, simply type the following:
print (f"{name} is {age} years old")
This allows you to put variables directly into the string, rather than having to format it afterwards or use the "+" operator. simply put a lowercase "f" before your strings in order to integrate variables in this way
+ 2
Hi Chris!
Someone asked the same thing a few weeks ago. So, I'm sharing this with you to understand the concept clearly
https://www.sololearn.com/discuss/2850362/?ref=app
+ 1
As Simon Sauter pointed out, the most simple way is to use:
print((name + ā is ā) + (age + ā years oldā)
Note that I have used spaces inside the quotation marks.
Another way is to use commas to seperate members inside the āprintā fuction, and the function will automatically add a space between members.
Try this:
print(āabcā, ādefā)
Output:
abc def