How to add dictionary in the code keeping the same logic? (Python)

Viewed 27

I have a code that I would like to add dictionary keeping the same logic:

found = True

n = int(input("Enter number: "))

stone_gohan = input("Enter Gohan: ").split()
st_gohan = stone_gohan

stone_picolo = input("Enter Picolo: ").split()
st_picolo = stone_picolo

for item in stone_gohan:
   if item not in st_picolo:
    found = False
    break
   else:
    st_picolo.remove(item)
    
for item in stone_picolo:
  if item not in st_gohan:
    found = False
    break
  else:
    st_gohan.remove(item)

if found:
   print("Go, gohan")
else:
   print("Oh, not now, Gohan! Let's try again next week.")

input example:

5

1 2 3 3 5

5 1 3 2 3

output example:

'Go, gohan'

0 Answers
Related