python declare string code example
Example 1: how to create string in python
string = "this is string"
string = 'this is also string'
Example 2: python variable
string = 'string'
integer = 5
boolean = True
Example 3: how to create a variable in python
variable1 = "value"
variable2 = 1000000
variable3 = 10000.0
variable4 = True
Example 4: strings in python
myString = "Hello world"
print(myString)
myArr = []
myArr.append(myString)
H = myString[0]
lowercase = myString.lower()
myInt = int(myString)
Example 5: variables in python
x = 5
y = "John"
print(x)
print(y)
Example 6: initialization string python
>>> x = None
>>> print type(x)
<type 'NoneType'>
>>> x = "text"
>>> print type(x)
<type 'str'>
>>> x = 42
>>> print type(x)
<type 'int'>