python ''' string code example
Example 1: print string python
str1 = "Hello World"
print(str1)
Example 2: string in python
# ways to dfefine string in python
string = "String"
string = str(string)
# Can Add strings
s1 = "Str"
s2 = "ing"
s = s1 + s2 # "String"
Example 3: strings in python
#A string is a type of data. There are many data types. It can be manipulated.
#It can be storerd as a variable
myString = "Hello world"
#WE can print it:
print(myString)
#You can append it to arraY:
myArr = []
myArr.append(myString)
#You can find the index of a character in a string:
H = myString[0]
#You can use methods on it:
lowercase = myString.lower()
#You can convert it into a integer provided it is a numerical string
myInt = int(myString)
#So thats the basics, hope i haven't left anything out.
Example 4: pyhon string
a = "Hello"
print(a)
Example 5: python string cut
# string [start:end:step]
string = "freeCodeCamp"
print(string[0:len(string)-1]) # freeCodeCam
print(string[0:5]) # freeC
print(string[2:6]) # eeCo
print(string[-1]) # p
print(string[-5:]) # eCamp
print(string[1:-4]) # reeCode
print(string[-5:-2]) # eCa
print(string[::2]) # feCdCm
Example 6: how to create a string in python
var1 = "A String"