0 like 0 dislike
ago in Tutorial & Interview questions by (7k points)

1 Answer

0 like 0 dislike
ago by (7k points)
selected ago by
 
Best answer

While Loop in Python

# Initialize variable i with value 0
i = 0
# Initialize an empty list
count = []

# Start executing the while loop untill the value of i is less than 8

while i < 8:
   print ('The number is %d' % i)
   count.append(i) # Append the value to the empty list
   i = i + 1 # Increment the value of variable i in steps of 1
   print ('The numbers in count list is:', count)

# Execute for loop using the values in count list

for numbers in count:
print ('The numbers from the count list are: %d' % numbers)

Register fast for winter training program at Goeduhub Technologies. We are providing winter training in AI-ML, IoT, Python, Hadoop and PLC-SCADA.

[[ CALL - 07976731765 ]]

...