Skip to content

Instantly share code, notes, and snippets.

@Skydrifa
Created April 28, 2021 13:31
Show Gist options
  • Save Skydrifa/1e4c8843df6047d19d41d7cf77585cdb to your computer and use it in GitHub Desktop.
Save Skydrifa/1e4c8843df6047d19d41d7cf77585cdb to your computer and use it in GitHub Desktop.
Differences between Print Concatenations
# Homework 9.3: Make String joining Lowercase
str_one = "Today Is a Beautiful Day vs" # i didn't added space, see the result spaces between words
str_two = "Today is a terrible Day"
print(str_one.lower() + str_two.lower()) # no space added
print(str_one.lower() + " " + str_two.lower()) # space add a virgula faz um espaço
print("%s %s" % (str_one.lower(), str_two.lower())) # space add
print("{0} {1}".format(str_one.lower(), str_two.lower())) # space add
# The preferred options are using the .format() method or using f-strings below:
print("{first} {second_str}".format(first=str_one.lower(), second_str=str_two.lower())) # space add
# The newest way of formatting strings is called f-string and it looks like this:
print(f"{str_one.lower()} {str_two.lower()}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment