I'm writing a simple program that takes 5 numbers, puts them in a list, divides each number by 2 and prints the output list.
list1 = input("Type 5 numbers: ").split()
for eachElement in list1:
list1.append(str(int(eachElement)//2))
print("final numbers are "," ".join(list1[5:]))
PROBLEM: The program hangs after the first input line. In the terminal, it takes the 5 numbers but never goes onto the next line.
Type 5 numbers: 56 67 84 45 78
What can be the problem? I have used input with split in many other programs, but it hangs sometimes and works most of the time.
list1you are iterating over? Theforloop becomes an infinite loop