I have been trying to create a program with python 2.7.
This program creates a random number. (nlist[r]
is saved in list[]
)
If list[0]
is 'do'
or 'ge'
or 'gi'
, just print list
and the program is ended.
If list[0]
is 'mo'
or 'yu'
, the while
loop starts.
When list[k]=='yu'
or 'mo'
, the loop must stop, print list
, and also end the program.
But this ended up in an infinite while loop...
Here is my code:
nlist=['do','ge','gi','yu','mo']
list=[]
def playYut():
import random
r=random.randrange(0,5)
list.append(nlist[r])
playYut()
if list[0]=='do' or list[0]=='gae' or list[0]=='girl':
for i in list:
print i
else:
k=0
while list[k]:
if list[k]=='yut' or list[k]=='mo':
playYut()
for i in list:
print i
else:
for i in list:
print i