Reputation: 21
word1 = input("Random Name (ex. Ryan):")
word2 = input("Your name (ex. why do you need an example of your name?):")
print("To:", word1, "@gmail.com")
print("From:", word2, "@outlook.com")
Now you almost need to ignore everything except, word 1 and word2 for now.
Im just wondering why is that the output is
To:name @gmail.com
and not To:[email protected]
Thanks in advance guys!
Upvotes: 1
Views: 64
Reputation: 2332
Because in python print
automatically adds spaces between the arguments of the print statement, i.e., things separated by commas. If you want to remove that, you can set the sep
keyword to a different separator besides a space. Set it to a blank string to have no separator.
>>> print('A','string','with','spaces.')
A string with spaces.
>>> print('A','string','with','no','spaces.', sep = '')
Astringwithnospaces.
Upvotes: 3
Reputation: 11615
You can do
print("To:" + word1 + "@gmail.com")
Or
print("To:%[email protected]" % word1)
Or
print("To:{}@gmail.com".format(word1))
Or as suggested in the comment:
print("To:{0:s}@gmail.com".format(word1))
To print the value the way you want
Doing print(some_val, some_val2, some_val3, ...)
will add a space between these values.
Upvotes: 3