Advertisement
sievrebo

Command Center

Aug 18th, 2019
389
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. data_num = list(map(int, input().split()))
  2.  
  3. data = input()
  4.  
  5. while not data == "END":
  6.     command = data.split()
  7.     if command[0] == "multiply":
  8.         if command[1] == "list":
  9.             data_num *= int(command[2])
  10.         elif command[1].isdigit():
  11.             if int(command[1]) in data_num:
  12.                 data_num = [num * int(command[2]) if num == int(command[2]) else num for num in data_num]
  13.             else:
  14.                 pass
  15.         else:
  16.             break
  17.     elif command[0] == "contains":
  18.         if int(command[1]) in data_num:
  19.             print("True")
  20.         else:
  21.             print("False")
  22.  
  23.     elif command[0] == "add":
  24.         if command[1].isdigit():
  25.             data_num.append(int(command[1]))
  26.         else:
  27.             list_num = list(map(int,command[1].split(",")))
  28.             data_num.extend(list_num)
  29.  
  30.     data = input()
  31. data_num.sort()
  32. print(*data_num)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement