Wednesday, 1 October 2014

Siri with a Tuple

I changed my siri to use a tuple:


 #Siri!!
restart = 'y'
while restart=='y':

 import random

 user_name = input("What is yor name?\n")

                                                                          #Write answers in a tuple.
 answer=(
 "Sure Thing",
 "Why not",
 "Siri Aproves",
 "HaHa Nice!",
 "Go for it",
 "So Cool!",
 "I'm Siri",
 "Cool Story",
 )



 print ("Hi",user_name)
 print ("Meet Siri.")

                                                                          #get the users questions.

 question= input ("Ask me for advice then press ENTER to shake me?\n")
 print ("Shaking...\n"*4)

                                                                          #Create a dice.
 choice=random.randint(0,7)

                                                                          #Print answer to the screen then restart
 print (user_name,"You asked -",question)
 print("Siri says:\n",answer[choice])
 restart= input("\n\n Press y key to to play again\n")


1 comment:

  1. Where are tuples used and why might they be useful?

    ReplyDelete