<div>Hello all, </div><div>I am a beginner to python and I am trying to make a simple program that takes in some names as input into a list and then randomly picks a vaule from that list as a winner.</div><div> </div><div>
Here is the code:</div><div> </div><div>import random</div><div> </div><div>choice = None</div><div> </div><div>names = [ ]</div><div> </div><div>while choice != "0":<br> print(<br> """<br>
0 - Exit<br> 1 - Enter a name<br> 2 - Pick a winner<br> """)<br> choice = input("Choice: ")<br> print()</div><div> </div><div> if choice == "0":<br>
print ("Goodbye.")</div><div> </div><div> elif choice == "1":<br> name = input("Please enter a name: ")<br> names.append(name)<br> print (names, "have been entered.")</div>
<div> </div><div> elif choice == "2":<br> pick = len(names)<br> win_number =random.randint(0,pick)<br> print (names[win_number], " is the winner!")</div><div> </div><div>input("/n/nPress enter to exit.")<br>
</div><div> </div><div>First problem, sometimes I get a error where the value is out of range. Problem becuase of the way I set up the random value.</div><div>Second problem, but not a big one, is when I print the lists of names as they are entered, I get quotations around the name.</div>
<div> </div><div>I'm sur I am over thinking this, but any help would be great.</div><div> </div><div>Thanks</div>