replace() and searched with rfind() and find(). Then two of its letters are changed with ord() and chr().
s = "banana"
t = s.replace("a", "o", 2)
print(t, s.rfind("an"), s.find("x"), "".join(chr(ord(c) - 32) for c in s[:2]))
What does the program print?Log in to join the discussion.
Loading…