Social Items

import random

def has_questionmark(qus):
 wordlist = qus.split()
 last_word = wordlist[-1]
 split_last_word = list(last_word)
 if '?' in split_last_word:
  return True


def has_special_words(qus):
 wordlist = qus.split()
 first_word = wordlist[0]
 first_word = first_word.lower()
 special_words = ['what', 'where', 'when', 'how', 'why', 'are','do','did']
 if first_word in special_words:
  return True
  
def is_a_yn_question(qus):
 wordlist = qus.split()
 first_word = wordlist[0]
 first_word = first_word.lower()
 special_words = ['do', 'did', 'are']
 if first_word in special_words:
  return True

def is_a_question(qus):
 if has_questionmark(qus) or has_special_words(qus):
  return True
  

print('\nSpeak to me!')
while True:
 question = input('')
 if question == 'q':
  break
 if is_a_question(question):
  if is_a_yn_question(question):
   choice = random.randint(0,1)
   if choice:
    print('Yes.\n')
   else:
    print('No...\n')
  
  
  
  
  
 else:
  print('This is not a question.')

Conversation Machine

import random

def has_questionmark(qus):
 wordlist = qus.split()
 last_word = wordlist[-1]
 split_last_word = list(last_word)
 if '?' in split_last_word:
  return True


def has_special_words(qus):
 wordlist = qus.split()
 first_word = wordlist[0]
 first_word = first_word.lower()
 special_words = ['what', 'where', 'when', 'how', 'why', 'are','do','did']
 if first_word in special_words:
  return True
  
def is_a_yn_question(qus):
 wordlist = qus.split()
 first_word = wordlist[0]
 first_word = first_word.lower()
 special_words = ['do', 'did', 'are']
 if first_word in special_words:
  return True

def is_a_question(qus):
 if has_questionmark(qus) or has_special_words(qus):
  return True
  

print('\nSpeak to me!')
while True:
 question = input('')
 if question == 'q':
  break
 if is_a_question(question):
  if is_a_yn_question(question):
   choice = random.randint(0,1)
   if choice:
    print('Yes.\n')
   else:
    print('No...\n')
  
  
  
  
  
 else:
  print('This is not a question.')