![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,827
Rep Power: 5
![]() |
SOLVED: Newbie question.
I've programmed a third of an engine for an RPG but I don't know what while does... :eek:
I see sometimes just while a: or while 1: I know that adding a condition afterwards loops the indentation lines until that condition becomes untrue. But what if there is no condition like the two I mentioned above? ![]() Last edited by Sane; Apr 14th, 2005 at 2:47 PM. |
|
|
|
|
|
#2 |
|
Programmer
Join Date: Feb 2005
Posts: 54
Rep Power: 4
![]() |
I am not sure what you are asking here.
while 1:
print "Stuck in an infinite loop"You would usually use it with a break statement. For example: while 1:
s = raw_input("Type yes to end: ")
if s == "yes":
break
else
print "Not ending!"Last edited by Moldz; Apr 14th, 2005 at 2:14 PM. |
|
|
|
|
|
#3 |
|
Programming Guru
![]() Join Date: Apr 2005
Posts: 1,827
Rep Power: 5
![]() |
Gah. I'm used to these just being called
"loop:" Stupid new terms...>_< Then why have I seen while a? o_O Well thanks. |
|
|
|
|
|
#4 |
|
Programmer
Join Date: Feb 2005
Posts: 54
Rep Power: 4
![]() |
Because a is a variable.
a = True
b = 0
while a:
print b
b += 1
if b == 3:
a = False |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|