mardi 28 novembre 2017

Why is this string comparison not working? (difflib)

This code should be printing "I am unit Alpha 07" when the user says something like "what's your name", but for some reason the if statement never returns true. Please help!

import difflib
    while True:
     talk = input("Please say something > ")
     temp = (difflib.get_close_matches(talk, ['What is your name?', 'Hello', 'peach', 'puppy'],1,0.2))
     print(temp)
     if temp == "['What is your name?']":
      print("I am unit Alpha 07")
      break
     continue

    input()

Here's a screenshot

Sorry if this is really stupid.

Aucun commentaire:

Enregistrer un commentaire