Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Strings

• Python supports concatenating strings using the addition operator.

h = "hello“
w = "world“
hw = h + " " + w
print(hw)
Strings
• Python also supports multiplying strings to form a string with a
repeating sequence.

h1 = "hello" * 10
print(h1)
Lists
• Lists can be joined with the addition operators.

even_numbers = [2,4,6,8,10]
odd_numbers = [1,3,5,7,9]
all_numbers = odd_numbers + even_numbers
print(all_numbers)
Lists
• Just as in strings, Python supports forming new lists with a repeating
sequence using the multiplication operator.

ls = [1,2,3] * 3
print(ls)

You might also like