|
Operations on strings and examples:
|
|
|
Multiline strings
|
|
x = """ This is a multiline string""" |
|
|
Get the character at a specific position
|
|
x = "Python Programming" |
|
|
Slicing
|
|
x = "Python Programming" |
|
|
Negative Indexing
|
|
x = "Python Programming" |
|
|
String Length
|
|
x = "Hello" |
|
|
Remove any whitespace from the beginning or the end
|
|
x = " Hello " |
|
|
Return the string in lower case
|
|
x = Hello |
|
Return the string in upper case
|
|
x = Hello |
|
|
Replace a string with another string
|
|
x = "Hello" |
|
|
Choose a separator and split string into substrings
|
|
x = "Python Programming" |
|
|
Check if a string is present in a text
|
|
txt = "Tunisia is a North African country" |
|
|
Concatenation
|
|
x = "Hello" |
|
|
Insert numbers into strings
|
|
quantity = 3 |
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.