String
a = “0123456”
print(a[1]) out:1 // n
— — — — —-
a = “012 3456”
print(len(a)) out:8 //a space is also considered a character
— — — — —
a = “0123456!”
print(“234” in a) out:TRUE
— — — — —
a = “0123456”
print(a[1:5]) out:1234 //from n to n-1
— — — — —
a = “0123456”
print(a[:5]) out:01234 // untill n-1
— — — — —
Get Dosiik1’s stories in your inbox
Join Medium for free to get updates from this writer.
a = “0123456”
print(a[2:]) out:23456 //from n untill the end
— — — — —
a = “Hello”
print(a.upper()) out:HELLO //this is a method which is used with a dot
//also we have lower() method
— — — — —
a = “Hello”
print(a.replace(“H”, “J”)) out:Jello! //this is a method
— — — — —
a = “Hello, World!”
print(a.split(“,”)) out:[‘Hello’, ‘ World!’] //splits the string into parts if it finds instances of the separator
— — — — —
age = 36
txt = “My name is John, I am “ + age
print(txt) out:ERROR
solution:
age = 36
txt = “My name is John, and I am {}”
print(txt.format(age))
out:My name is John, and I am 36 //dont forget about {}
//insert numbers into strings
c = “i’m”
b = “so”
a = “curious”
output = “*** {2} *** {1} * {0}”
print(output.format(a, b, c))
out:*** i’m *** so * curious
//you can use index numbers {0}
txt = “lol \”KEK\” cheburek”
print(txt)
out:lol “KEK” cheburek
//the escape character allows you to use double quotes





