xxxxxxxxxx
# theres a lot of ways to concatenate in python
# here are all examples that i know:
world = 'World!'
number = '69'
a = 'Hello ' + ' ' + world + ' ' + number
b = 'Hello {} {}'.format(world, number)
c = f'Hello {world} {number}' # most easy / beginner friendly
d = 'Hello %s %s', % (world, number)
e = 'Hello', world, number
# all of these will print "Hello World! 69"
print(a)
print(b)
print(c)
print(d)
print(e)
xxxxxxxxxx
first_name = 'Albert'
last_name = 'Einstein'
full_name1 = first_name + last_name
print(full_name1)
full_name2 = first_name + ' ' + last_name
print(full_name2)
# Output - AlbertEinstein
# Output - Albert Einstein
xxxxxxxxxx
my_list = ['a', 'b', 'c', 'd']
my_string = ','.join(my_list)
# Output = 'a,b,c,d'
xxxxxxxxxx
x = ‘apples’
y = ‘lemons’
z = “In the basket are %s and %s” % (x,y)
xxxxxxxxxx
x="String"
y="Python"
d="+"
c = "We can concatenation " + y + x + "with" + d + "Operator"
print(c)
xxxxxxxxxx
# Хоёр мөрийн агуулгыг нэг мөр болгон нэгтгэхийн тулд Python нь + операторыг өгдөг.
# Мөрүүдийг холбох энэ процессыг холболт гэж нэрлэдэг.
x = 'One fish, '
y = 'two fish.'
z = x + y
print(z)
# Output: One fish, two fish.