79833991

Date: 2025-11-30 15:26:07
Score: 1
Natty:
Report link

Use break to exit the loop as soon as the element is found

numbers = (2, 4, 6, 8, 10, 12)

x = int(input("Enter a number to search: "))

i = 0

while i < len(numbers):
    if numbers[i] == x:
        print("Number found at index", i)
        break   # stop the loop
    i += 1
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Mario