Soooo, this is killing me right now. Should've asked a lot earlier, but there we go. So I think there is something wrong with the zip that I've made, and it's driving me mad. If there's an another way to do this, please let me konw, but if you teach me how to use zip, that'll be great to. Also if someone can point out all the things I've messed up, that would be fantastic.
fun_string = """In ___0___, crazy ___1___ with ___2___, ate a meal called ___3___ on a grill""",
horror_string = """In ___0___ owned by ___1___, many were killed by ___2___ because of huanted ___3___""",
mystery_string = """The most mysterious place on Earth is ___0___, next to ___1___'s house because of a ___2___ living in ___3___"""
answers = [ ]
blanks = ["___0___", "___1___", "___2___", "___3___"]
def select_level():
user_input = raw_input("""Type in a story you wish to play: """)
while user_input not in ["Fun","Horror","Mystery"]:
user_input = raw_input("Invalid story. Please try again: ")
if user_input == "Fun":
quiz(fun_string, answers, blanks)
if user_input == "Horror":
quiz(horror_string, answers, blanks)
if user_input == "Mystery":
quiz(mystery_string, answers, blanks)
def zip(*iterables):
# zip('ABCD', 'xy') --> Ax By
iterables = map(iter, iterables)
while iterables:
yield tuple(map(next, iterables))
def quiz(quiz_string, answers, blanks):
print quiz_string
for answer, question in zip(answers, blanks):
raw_input ("Type in a word: ")
quiz_string = quiz_string.replace(blanks[1], answers)
if blanks == None:
print quiz_string
print """Welcome to kis ReMadlibs!!!!"""
print """Select a story you wish to particiate!!"""
print """Fun, Horror, Mystery"""
print select_level()
It's not clear why you're using your own zip() instead of Python's zip(), nor why you believe you need zip() at all. You can get this program to work by simplifying the code:
fun_string = """In ___0___, crazy ___1___ with ___2___, ate a meal called ___3___ on a grill"""
horror_string = """In ___0___ owned by ___1___, many were killed by ___2___ because of huanted ___3___"""
mystery_string = """The most mysterious place on Earth is ___0___, next to ___1___'s house because of a ___2___ living in ___3___"""
answers = []
blanks = ["___0___", "___1___", "___2___", "___3___"]
def select_level():
user_input = raw_input("Type in a story you wish to play: ")
while user_input not in ["Fun", "Horror", "Mystery"]:
user_input = raw_input("Invalid story. Please try again: ")
if user_input == "Fun":
quiz(fun_string, answers, blanks)
elif user_input == "Horror":
quiz(horror_string, answers, blanks)
elif user_input == "Mystery":
quiz(mystery_string, answers, blanks)
def quiz(quiz_string, answers, blanks):
print quiz_string
for blank in blanks:
answer = raw_input("Type in a word: ")
quiz_string = quiz_string.replace(blank, answer)
answers.append(answer)
print quiz_string
print """Welcome to kis ReMadlibs!!!!"""
print """Select a story you wish to particiate!!"""
print """Fun, Horror, Mystery"""
select_level()