Question: HI I need help on this assignment can some please help me. I supposed to use slice notation but I dont know how to use

HI I need help on this assignment can some please help me. I supposed to use slice notation but I dont know how to use it in this program to iterating over a list.

Modify the program (copied from above) using slice notation to iterate over a copy of the list.

nums1 = [] nums2 = []

user_input = input('Enter first set of numbers: ') tokens = user_input.split() # Split into separate strings

# Convert strings to integers for pos, val in enumerate(tokens): nums1.append(int(val)) print('%d: %s' % (pos, val))

user_input = input('Enter second set of numbers:') tokens = user_input.split()

# Convert strings to integers print() for pos, val in enumerate(tokens): nums2.append(int(val)) print('%d: %s' % (pos, val)) # Remove elements from nums1 if also in nums2 print() for val in nums1: if val in nums2: print('Deleting %d' % val) nums1.remove(val)

# Print new numbers print(' Numbers only in first set:', end=' ') for num in nums1: print(num, end=' ')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!