Answers for "loop command python"

4

python loop

# A loop is used to iterate over a sequence
# The format of a loop is
for variable in object:
  pass

# A common use of a for loop is using the range() function
for num in range(1, 10):
  print(num)
  
# It can also be used with a list
new_list = ["Number 1", "Number 2", "Number 3", "Number 4"]
for x in new_list:
  print(x)
Posted by: Guest on April-27-2021
1

how to make a loop in python

x = 0
while True: #execute forever
	x = x + 1
	print(x)
Posted by: Guest on November-09-2020

Python Answers by Framework

Browse Popular Code Answers by Language