Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Until statement/loop python?

Is there an until statement or loop in python? This does not work:

x = 10
list = []
until x = 0:
    list.append(raw_input('Enter a word: '))
    x-=1
like image 907
user4548858 Avatar asked Dec 03 '25 15:12

user4548858


1 Answers

The equivalent is a while x1 != x2 loop.

Thus, your code becomes:

x = 10
lst = [] #Note: do not use list as a variable name, it shadows the built-in
while x != 0:
    lst.append(raw_input('Enter a word: '))
    x-=1
like image 75
A.J. Uppal Avatar answered Dec 05 '25 05:12

A.J. Uppal



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!