If you use:
print ("Right... So your name is", name,".")
You will notice that the output is:
Right... So your name is Raven .
Look at is and name (Raven). You can note in the output an space (is Raven), that is because print() have a default argument called sep an by default it's print("Right... So your name is", name,".", sep = ' '). That argument is an string that it's added at the end of each piece of string concatenated with a coma , in the print function.
So if you do print('A','B') it will be A B, because when you concatenate A and B, print will add ' ' (and space) as glue.
You can configure it: print('A','B', sep='glue') would print AglueB!
To solve your problem you can do two options.
- Change
sep = '' and add an space after is: print ("Right... So your name is ", name,".", sep='')
- Or, concatenate using
+ the last two strings: print ("Right... So your name is", name + ".")
Also there are a lot of another ways like: (I ordered them by worst to best in my subjetive opinion...)
print("Right... So your name is %s." % name).
print("Right... So your name is {}.".format(name)).
print(f"Right... So your name is {name}.")
Link with documentation:
- Python Official Documentation
- Python 3 Course (Use of
sep and ,, +, %s, .format(), f-string and use of string class)
- PyFormat (Basic and advanced use of
%s, %d, .format(), value conversion, datetime, ).
P.S: This isn't part of the answer, it's just a note.
print (something) don't need the space --> print(something).
- Futhemorer
sep = ' ' there is also called end = '\n' that determine the end of a print (\n = new line).
P.S 2: Thanks Ouss for the idea of add some documentations links. I've just learnt that you can do print(%(key)s % mydict)!