How do I increment strings in python? For example, x should change to y, y to z, z to a. Please note that only the last letter should change. For example, the word Ved should change to Vee, and not Wfe
Other examples: xyz should increment to xza.
def increment(password):
char = password[-1]
i = ord(char[0])
i += 1
if char == 'z':
return password[:-2] + increment(password[-2]) + 'a'
char = chr(i)
return password[:-1] + char