Python
2: Escape Sequence
3: Comments
4: Escape Sequence as Normal Text
5: Print Emoji
6: Python as Calculator
7: Strings Concatenation
8: Input
9: int function
10: Variables
11: String Formatting
12: String Indexing
13: String Slicing
14: Step Argument
15: Some useful function and methods
16: Strip Method
17: Find and Replace method
Chapter 7: Strings Concatenation
We can concatenate two or more strings directly. However, to combine a string with a number, the number must first be converted into a string. Below are some methods to convert a number into a string, as shown in the examples
Note: We can multiply a string by a number to repeat it. In Python, strings are immutable, meaning the characters in a string cannot be changed once it is defined.
first_name = "Free"
last_name = "Learning"
full_name = first_name + last_name
print(full_name) # no space
Output: FreeLearning
full_name = first_name + " " + last_name
print(full_name)
Output: Free Learning
print(first_name + 6) # Error (string + number)
print(first_name + "6") # No Error (number 6 converted into string)
Output: Free6
print(first_name + str(6)) # No Error (number 6 converted into string)
Output: Free6
print((full_name + "\t") * 2)
Output: Free Learning Free Learning