how to create a loop that ends with "done" python 3.4 -
how to create a loop that ends with "done" python 3.4 -
im trying create programme uses list store names of notable celebrities. need to utilize loop prompt user names , add together them list. when user enters "done" loop should stop. programme should output number of celebrities entered. finally, programme should utilize loop display celebrity names, each on own line, , "done" should not in celebrities list did go wrong here because shows "celebrite name" on , on again. professor had if helps any.
your celebrity programme needed more context. looked @ code , tell do, user showed celebrity name on , on again.
list = [] while(1): name = input("enter celebrity name:") if name == "done": break; else: list += [name] print(len(list)) in range(len(list)): print(list[i])
ok :
never utilize list variable name - bad form, , problem eventually. there simpler way loop around content of list, don't need utilize index. your programme not tell user how utilize program, or how stop entering names - maybe professor suggesting programme should generate useful instructions. when finishes prints number, , list of names, maybe useful info there help too. it improve practice utilizewhile true
, rather while (1)
in python. for number 2 - code :
a=["a","b","c","d","e"] in a: print (i)
python python-3.x
Comments
Post a Comment