In [1]: s = "python"  
  
In [2]: s.upper()  
Out[2]: 'PYTHON'  
  
In [3]: s.lower()  
Out[3]: 'python'  
  
In [4]: msg = "abrakadabra"  
  
In [5]: msg.count('ra')  
Out[5]: 2  
  
In [6]: msg.count('ra', 4, 11)  
Out[6]: 1
 
s.find('smth', start, end) # finds first index that is included. If index isn't find the output will be -1
s.rfind('smth', start, end) # finds string from the end 
 
s.index() # the same as find but it shows error when there is no found element
 
 
In [3]: s.replace('py', 'hi')  
Out[3]: 'hithon'
 
In [15]: s.isalpha()  
Out[15]: True  
  
In [16]: 'Hi man'.isalpha()  # False because there is space between hi and man. space isn't a string
Out[16]: False  
  
In [17]: s.isdigit()  
Out[17]: False  
  
In [18]: '6'.isdigit()  
Out[18]: True
 
 
>>> g  
['1', '2', '3', '4']  
>>> ', '.join(g)  
'1, 2, 3, 4'  
 
 
 
In [7]: a = 'Alex Treizer Faura'  
  
In [8]: a  
Out[8]: 'Svet Jpp Faura'  
  
In [9]: ", ".join(a.split())  
Out[9]: 'Svet, Jpp, Faura'
 
 
In [10]: "      hello world       \n".strip()  
Out[10]: 'hello world'  
  
In [11]: "      hello world       \n".rstrip()  
Out[11]: '      hello world'  
  
In [12]: "      hello world       \n".lstrip()  
Out[12]: 'hello world       \n'


Reference:

  • Kind Python. Sergey Balakiriev