Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- spell_that_needs_decyprication = input()
- current_spell = input()
- while current_spell != "Abracadabra":
- spell_list = current_spell.split()
- command = spell_list[0]
- if command == "Abjuration":
- spell_that_needs_decyprication = spell_that_needs_decyprication.upper()
- print(spell_that_needs_decyprication)
- elif command == "Necromancy":
- spell_that_needs_decyprication = spell_that_needs_decyprication.lower()
- print(spell_that_needs_decyprication)
- elif command == "Illusion":
- index = int(spell_list[1])
- letter = spell_list[2]
- if index < len(spell_that_needs_decyprication):
- first_part = spell_that_needs_decyprication[:index]
- second_part = spell_that_needs_decyprication[index + 1:]
- spell_that_needs_decyprication = first_part + letter + second_part
- print("Done!")
- else:
- print("The spell was too weak.")
- elif command == "Divination":
- first_substring = spell_list[1]
- second_substring = spell_list[2]
- if re.search(first_substring, spell_that_needs_decyprication, re.IGNORECASE):
- pattern = re.compile(first_substring, re.IGNORECASE)
- spell_that_needs_decyprication = pattern.sub(second_substring, spell_that_needs_decyprication)
- print(spell_that_needs_decyprication)
- elif command == "Alteration":
- substring = spell_list[1]
- spell_that_needs_decyprication = spell_that_needs_decyprication.replace(substring, "")
- print(spell_that_needs_decyprication)
- else:
- print("The spell did not work!")
- current_spell = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement