Код: Выделить всё
import time
def intro():
print "Welcome! This program will convert inches to centimeters for you.\n"
convert()
def convert():
input_cm = input(("Inches: "))
inches_conv = input_cm * 2.54
print "Centimeters: %f\n" % inches_conv
time.sleep(3)
restart = str(input("Do you wish to make another conversion? [y]Yes or [n]no: "))
if restart == 'y':
convert()
elif restart == 'n':
end_fast()
else:
print "I didn't quite understand that answer. Terminating."
end_slow()
def end_fast():
print "This program will close in 5 seconds."
time.sleep(5)
def end_slow():
print "This program will close in 30 seconds."
time.sleep(30)
intro()
Traceback (последний вызов последним):
Файл «C:\Users\Sam\Programming\Python\the Hard Way\ex5.4.py», строка 29, в
intro()
Файл "C:\Users\Sam\Programming\Python\the hard way\ex5.4.py", строка 5, во введении
Convert()
Файл "C:\Users\Sam\Programming\ Python\the hard way\ex5.4.py", строка 12, в Convert
restart = str(input("Вы хотите выполнить еще одно преобразование? [y]Да или [n]нет?\n"))
Файл "", строка 1, в
NameError: имя 'y' не определено
Помощь оценена по достоинству.
Подробнее здесь: https://stackoverflow.com/questions/182 ... ot-defined