# -*- coding: utf-8 -*-
"""
fill-in-the-blanks1.py
"""
# -*- coding: utf-8 -*-
"""
p1
"""
level1 = '''The __1__ command can print out any types of a variable. __2__ defines a function that could be
called out at any place in the document. A __3__ is a group of strings, variables or numbers. __3__ can also be
printed by the __1__ command. __4__ is the statement of true or false.'''
level2 = '''A ___1___ is created with the def keyword. You specify the inputs a ___1___ takes by
adding ___2___ separated by commas between the parentheses. ___1___ by default return ___3___ if you
don't specify the value to return. ___2___ can be standard data types such as string, number, dictionary,
tuple, and ___4___ or can be more complicated such as objects and lambda functions.'''
level3 = '''__1__ , __2__ , __3__ , all belongs to the if statement. __1__ will be used at the beginning of the
if statement, __2__ will be used in the middle between the __4__ and the __5__ statement. '''
variables1 = ["print", "def", "list", "boolean"]
variables2 = ["function", "parameter", "false", "list"]
variables3 = ["if", "elif", "else", "first"]
d = "__1__"
e = "__2__"
f = "__3__"
g = "__4__"
h = "__5__"
def replacevar(string, variable, inputa, finish):
string.split()
while True:
if inputa == variable[0]:
string = string.replace(d, inputa)
finish = ""
finish = finish.join(string)
return finish
break;
else:
print ("Your Answer is incorrect, pls try again")
return True
level = input("Which level do you want to play? (1, 2 or 3)")
if level == "1":
print (level1)
useranswer = input("Please enter the value for variable NO.1: ")
replacevar(level1, variables1, useranswer, finish1)
print (finish1)
Python код, как описано выше, это только первая часть программы, которая просит вас заполнить пробел и заменить ..... словом вы ввели, если ваш ответ правильный. Но когда я запускаю программу, после того, как я набрал 1, вопрос показал, как и ожидалось, но после того, как я набрал «print» (без «») для ответа для первой переменной «», он не печатает строка с замещенными словами.код оленья кожа печати ничего
Кажется, что-то отсутствует, переменная 'finish1' не определена нигде. – fjarri