How to Create, Join and Intercept a String in Python


In this example we will show how to create, join, and intercept a string in python.

Source Code

#! /usr/bin/env python3
# -*- coding: UTF-8 -*-

a = "Hello"
b = "Python"

print("the result of  a + b :", a + b)
print("the result of  a * 2 :", a * 2)
print(" a[1]:", a[1])
print("a[1:4]:", a[1:4])

if ("H" in a):
    print("H is in var a")
else:
    print("H is not in var  a")

if ("M" not in a):
    print("M is not in var a ")
else:
    print("M is in var a")

print(r'n')
print(R'n')

Output:

the result of  a + b : HelloPython
the result of  a * 2 : HelloHello
 a[1]: e
a[1:4]: ell
H is in var a
M is not in var a
n
n
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments