Question: Walk through the following code that counts how many adjacent duplicates are in a sequence of non - negative integer inputs, using a negative value

Walk through the following code that counts how many adjacent duplicates are in a sequence of non-negative integer inputs, using
a negative value as the sentinel. Assume the inputs are 1,2,2,4,4,-1
duplicates =0
value = int(input("Enter a value: "))
while value >=0 :
previous = value
value = int(input("Enter a value: "))
if value == previous :
duplicates = duplicates +1
print(duplicates)
Walk through the following code that counts how

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 Programming Questions!