how to define a string in python code example
Example 1: how to create string in python
string = "this is string"
string = 'this is also string'
Example 2: python string in string
>>> str = "Messi is the best soccer player"
>>> "soccer" in str
True
>>> "football" in str
False
Example 3: strings in python
myString = "Hello world"
print(myString)
myArr = []
myArr.append(myString)
H = myString[0]
lowercase = myString.lower()
myInt = int(myString)
Example 4: {} string python
txt1 = "My name is {fname}, I'm {age}".format(fname = "John", age = 36)
txt2 = "My name is {0}, I'm {1}".format("John",36)
txt3 = "My name is {}, I'm {}".format("John",36)
Example 5: how to create a string in python
var1 = "A String"
Example 6: how to write string in python
name = "john"