prusev71

Mock Exam 4: Greater Number

Jun 16th, 2024
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | Software | 0 0
  1. output = []
  2.  
  3. lst1 = input().split(',')
  4. lst2 = input().split(',')
  5.  
  6. for i in range(len(lst1)):
  7. lst1[i] = int(lst1[i])
  8.  
  9. for i in range(len(lst2)):
  10. lst2[i] = int(lst2[i])
  11.  
  12. for i in range(len(lst1)):
  13.  
  14. if lst1[i] in lst2:
  15.  
  16. x = lst2.index(lst1[i])
  17.  
  18. if x == len(lst2) - 1:
  19. output.append(-1)
  20.  
  21. else:
  22.  
  23. if lst2[x+1] > lst1[i]:
  24.  
  25. output.append(lst2[x+1])
  26.  
  27. else: output.append(-1)
  28.  
  29. print(*output, sep = ',')
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment