Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def take_odd(text):
- new_text = ''
- for i, letter in enumerate(text):
- if i % 2 != 0:
- new_text += letter
- print(new_text)
- return new_text
- def cut_text(text, idx, length_):
- substring = text[idx: idx + length_]
- text = text.replace(substring, '', 1)
- print(text)
- return text
- def substitute_text(text, substring_, substitute_):
- if substring_ in text:
- text = text.replace(substring_, substitute_)
- print(text)
- else:
- print("Nothing to replace!")
- return text
- def main():
- password = input()
- while True:
- command = input()
- if command == "Done":
- break
- data = command.split()
- command = data[0]
- if command == "TakeOdd":
- password = take_odd(password)
- elif command == "Cut":
- index, length = int(data[1]), int(data[2])
- password = cut_text(password, index, length)
- elif command == "Substitute":
- substring, substitute = data[1], data[2]
- password = substitute_text(password, substring, substitute)
- print(f"Your password is: {password}")
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement