python počas slučky
# while True loop
while True:
print("This will continue to print this forever")
# while variable loop
value = 5
while value = 5:
# Since this is true, this will continue on forever
print("Yes")
Python počas Slučky
# Program to add natural
# numbers up to
# sum = 1+2+3+...+n
# To take input from the user,
# n = int(input("Enter n: "))
n = 10
# initialize sum and counter
sum = 0
i = 1
while i <= n:
sum = sum + i
i = i+1 # update counter
# print the sum
print("The sum is", sum)
Python počas slučky
i = 0
while i < 10:
print(i)
i += 1