Advertisement
Nightamer

Untitled

Apr 2nd, 2023
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. import re
  2. spell_that_needs_decyprication = input()
  3. current_spell = input()
  4.  
  5. while current_spell != "Abracadabra":
  6.     spell_list = current_spell.split()
  7.     command = spell_list[0]
  8.     if command == "Abjuration":
  9.         spell_that_needs_decyprication = spell_that_needs_decyprication.upper()
  10.         print(spell_that_needs_decyprication)
  11.     elif command == "Necromancy":
  12.         spell_that_needs_decyprication = spell_that_needs_decyprication.lower()
  13.         print(spell_that_needs_decyprication)
  14.     elif command == "Illusion":
  15.         index = int(spell_list[1])
  16.         letter = spell_list[2]
  17.         if index < len(spell_that_needs_decyprication):
  18.             first_part = spell_that_needs_decyprication[:index]
  19.             second_part = spell_that_needs_decyprication[index + 1:]
  20.             spell_that_needs_decyprication = first_part + letter + second_part
  21.             print("Done!")
  22.         else:
  23.             print("The spell was too weak.")
  24.     elif command == "Divination":
  25.         first_substring = spell_list[1]
  26.         second_substring = spell_list[2]
  27.         if re.search(first_substring, spell_that_needs_decyprication, re.IGNORECASE):
  28.             pattern = re.compile(first_substring, re.IGNORECASE)
  29.             spell_that_needs_decyprication = pattern.sub(second_substring, spell_that_needs_decyprication)
  30.             print(spell_that_needs_decyprication)
  31.     elif command == "Alteration":
  32.         substring = spell_list[1]
  33.         spell_that_needs_decyprication = spell_that_needs_decyprication.replace(substring, "")
  34.         print(spell_that_needs_decyprication)
  35.     else:
  36.         print("The spell did not work!")
  37.     current_spell = input()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement