Cómo hacer un bucle en Python
while True:
#yourcode here
ultra
while True:
#yourcode here
for x in range(6): #The Loop
print(x) #Output 0,1,2,3,4,5
x = 0
while True: #execute forever
x = x + 1
print(x)
for i in range (1,10,1)
print(i)
# For loop where the index and value are needed for some operation
# Standard for loop to get index and value
values = ['a', 'b', 'c', 'd', 'e']
print('For loop using range(len())')
for i in range(len(values)):
print(i, values[i])
# For loop with enumerate
# Provides a cleaner syntax
print('\nFor loop using builtin enumerate():')
for i, value in enumerate(values):
print(i, value)
# Results previous for loops:
# 0, a
# 1, b
# 2, c
# 3, d
# 4, e
# For loop with enumerate returning index and value as a tuple
print('\nAlternate method of using the for loop with builtin enumerate():')
for index_value in enumerate(values):
print(index_value)
# Results for index_value for loop:
# (0, 'a')
# (1, 'b')
# (2, 'c')
# (3, 'd')
# (4, 'e')
print("this is a test for the totorail")