Created
April 28, 2021 13:31
-
-
Save Skydrifa/1e4c8843df6047d19d41d7cf77585cdb to your computer and use it in GitHub Desktop.
Differences between Print Concatenations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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