import rhinoscriptsyntax as rs
def myfavorthings():
things=[]
while True:
count=len(things)
prompt=“What is your {0}th most favorite thing?”.format(count+1)
if count==0:
prompt=“What is your most favorite thing?”
elif count==1:
prompt=“What is your second most favorite thing?”
elif count==2:
prompt=“What is your third most favorite thing?”
answer=rs.GetString(prompt)
if answer is None:break
things.append(answer)
if len(things)==0:return
print “Your”,len(things),“favorite things are:”
for i,thing in enumerate(things):print i+1,“.”,thing
myfavorthings()
import rhinoscriptsyntax as rs
def myfavorthings():
things=[]
while True:
count=len(things)
prompt="What is your {0}th most favorite thing?".format(count+1)
if count==0:
prompt="What is your most favorite thing?"
elif count==1:
prompt="What is your second most favorite thing?"
elif count==2:
prompt="What is your third most favorite thing?"
answer=rs.GetString(prompt)
if answer is None: break
things.append(answer)
if len(things)==0: return
print "Your",len(things),"favorite things are:"
for i,thing in enumerate(things):print i+1,".",thing
myfavorthings()
谢谢版主,应该是第14句,if answer is None: break,这个None的理解,回车不算None吗?