Reputation: 67
I'm very new to Python and programming in general, so please bear with me while reading this. I'm using Python 3.6.1. Here is my code:
import random
greetings = ["how are you", "hello", "hey", "hi", "whats up"]
special_characters = [".", "?", "!"]
def main():
i = input()
if i in greetings or greetings and special_characters:
print(random.choice(greetings) + random.choice(special_characters))
main()
else:
print("Sorry, I don't understand what you just said.")
main()
main()
The problem is, when I try saying something like "hey!" or "hi," it comes up with this error message:
NameError: name 'main' is not defined
I've tried multiple times to fix this, but I simply couldn't figure out the solution.
Upvotes: 0
Views: 42