# File: ChapterStrings/stringfunctions.py # Python: L.count(x), L.find(x), L.replace('old', 'new') """ a al la an n t tu ur ri in ng ga al la an n t tu ur ri in ng g The number of occurences of u is: 1 Find first position of a: 0 Delete letter a: ln turing Replace a with X: XlXn turing """ def main(): S = "alan turing" # S global variable n = len(S) # length of the string for i in range(n): # print letters twice print(S[i],S[i],end="") for c in S: # same print(c,c,end="") print("\nThe number of occurences of u is: ", S.count('u')) print("Find first position of a:", S.find('a')) print("Delete letter a: ", S.replace('a', '')) # deletes ALL occurrences print("Replace a with X: ", S.replace('a', 'X')) main()