<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><div>I'm stuck on two problems from the Absolute Beginners book. The first is simple. I am trying to print all the words in the list in random order without repeats, but it always shows None for some reason.</div><div><br></div><div><div><span class="Apple-style-span" style="font-size: x-small;">#Program prints list of words in random order with no repeats</span></div><div><span class="Apple-style-span" style="font-size: x-small;"><br></span></div><div><span class="Apple-style-span" style="font-size: x-small;">import random</span></div><div><span class="Apple-style-span" style="font-size: x-small;"><br></span></div><div><span class="Apple-style-span" style="font-size: x-small;">#List of words</span></div><div><span class="Apple-style-span" style="font-size: x-small;"><br></span></div><div><span
 class="Apple-style-span" style="font-size: x-small;">list = ["first", "second", "third", "fourth","fifth"]</span></div><div><span class="Apple-style-span" style="font-size: x-small;"><br></span></div><div><span class="Apple-style-span" style="font-size: x-small;">#Randomize word order</span></div><div><span class="Apple-style-span" style="font-size: x-small;"><br></span></div><div><span class="Apple-style-span" style="font-size: x-small;">order = random.shuffle(list)</span></div><div><span class="Apple-style-span" style="font-size: x-small;">&nbsp;&nbsp; &nbsp;</span></div><div><span class="Apple-style-span" style="font-size: x-small;">#Print words in random order</span></div><div><span class="Apple-style-span" style="font-size: x-small;">print(order)</span></div><div><span class="Apple-style-span" style="font-size: x-small;"><br></span></div><div><span class="Apple-style-span" style="font-size: x-small;">input("\n\nPress the Enter to
 exit")</span></div></div><div><span class="Apple-style-span" style="font-size: x-small;"><br></span></div><div><span class="Apple-style-span" style="font-size: x-small;"><br></span></div><div><span class="Apple-style-span" style="font-size: small;">The other question is: "Improve the program by adding a choice that lets the user enter a name and get back a grandfather. You should still only use one list of son-father pairs. Make sure to include several generations in list so a match can be found." The only thing I have done is adding choice 5 with its basic elif block and adding another name in each of the three sequences&nbsp;</span><span class="Apple-style-span" style="font-size: small; ">in the list</span><span class="Apple-style-span" style="font-size: small; ">, but I am completely stuck otherwise.</span></div><div><span class="Apple-style-span" style="font-size: small; "><br></span></div><div><span class="Apple-style-span" style="font-size:
 x-small;"><div>#User can enter name of male and name of his father will show</div><div>#Allow user to add, replace, and delete son-father pairs.</div><div>#Also have the user enter a name to get back a grandfather</div><div><br></div><div>#Setting values</div><div>sondad = {"Vincent": "Ramon": "Lolo","Jesus": "God": "Unknown", "Simba": "Mufasa": "Lion"}</div><div><br></div><div>choice = None</div><div>while choice != "0":</div><div><br></div><div>&nbsp;&nbsp; &nbsp;print(</div><div>&nbsp;&nbsp; &nbsp;"""</div><div>&nbsp;&nbsp; &nbsp;Who's Your Daddy?!</div><div>&nbsp;&nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;0 - Quit</div><div>&nbsp;&nbsp; &nbsp;1 - Look Up Pair</div><div>&nbsp;&nbsp; &nbsp;2 - Add a Pair</div><div>&nbsp;&nbsp; &nbsp;3 - Replace a Pair</div><div>&nbsp;&nbsp; &nbsp;4 - Delete a Pair</div><div>&nbsp;&nbsp; &nbsp;5 - Look up a Grandfather</div><div>&nbsp;&nbsp; &nbsp;</div><div>&nbsp;&nbsp; &nbsp;"""</div><div>&nbsp;&nbsp;
 &nbsp;)</div><div><br></div><div>&nbsp;&nbsp; &nbsp;choice = input("Choice: ")</div><div>&nbsp;&nbsp; &nbsp;print()</div><div><br></div><div>&nbsp;&nbsp; &nbsp;# exit</div><div>&nbsp;&nbsp; &nbsp;if choice == "0":</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;print("Good-bye.")</div><div><br></div><div>&nbsp;&nbsp; &nbsp;# look up pair</div><div>&nbsp;&nbsp; &nbsp;elif choice == "1":</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;choice = input("Which pair do you want to look up?: ")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if choice in sondad:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dad = sondad[choice]</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\n", choice,"is son to:", dad)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\nSorry, I don't know", choice)</div><div><br></div><div>&nbsp;&nbsp; &nbsp;# add a father</div><div>&nbsp;&nbsp; &nbsp;elif choice ==
 "2":</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;choice = input("Who is the son you want to add?: ")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if choice not in sondad:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dad = input("\nWho's the father?: ")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sondad[choice] = dad</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\n", dad, "has been added.")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\nThat pair already exists! &nbsp;Try replacing them.")</div><div><br></div><div>&nbsp;&nbsp; &nbsp;# replace a father</div><div>&nbsp;&nbsp; &nbsp;elif choice == "3":</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;choice = input("Which son do you want to replace a father?: ")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if choice in sondad:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dad = input("Who's the
 father?: ")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sondad[choice] = dad</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\n", choice, "has been replaced.")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\nThey don't exist! Try adding them.")</div><div>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp;# delete a pair</div><div>&nbsp;&nbsp; &nbsp;elif choice == "4":</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;choice = input("Which pair do you want to delete?: ")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if choice in sondad:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;del sondad[choice]</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\nOkay, I deleted", choice)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\nI can't do that!", choice, "don't
 exist.")</div><div><br></div><div>&nbsp;&nbsp; &nbsp;# look up grandfather:</div><div>&nbsp;&nbsp; &nbsp;elif choice == "5":</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;choice = input("Who's grandfather are you looking up?: ")</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;if choice in sondad:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;dad = sondad[choice]</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\n", choice,"is grandson to:", dad)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;else:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;print("\nSorry, I don't know", choice)</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp;# some unknown choice</div><div>&nbsp;&nbsp; &nbsp;else:</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;print("\nSorry, but", choice, "isn't a valid choice.")</div><div>&nbsp;&nbsp;</div><div>input("\n\nPress the enter key to
 exit.")</div><div>&nbsp;&nbsp; &nbsp;</div><div><br></div></span></div><div></div><div><br></div><div style="position:fixed"></div>


<!-- cg2.c902.mail.ac4.yahoo.com compressed/chunked Fri Jun 10 01:22:23 UTC 2011 -->
<div id="myEventWatcherDiv" style="display:none;"></div></div></body></html>