프로그래밍의 초보자. Head First Programming 책을 사용하여 스스로 가르치려고합니다. 이 다음 코드를 작동시킬 수 없습니다.
def make_smoothie():
juice = input("What juice would you like?")
fruit = input("Ok- and how about the fruit?")
print "Thanks. Lets go!"
print "Crushing ice..."
print "Blending the %d" % fruit
print "Now adding in the %d juice" %juice
print "Finished! There's your %d and %d smoothie" %(fruit, juice)
print ("Welcome to smoothie")
another ="Y"
while another=="Y":
make_smoothie()
another = input ("How about another (Y/N)?")
주스 또는 과일에 대한 입력이 정의되지 않았다는 오류가 계속 발생합니다.
그냥 추측 ... 파이썬 2를 사용하고 있다면 ... raw_input
대신 사용하십시오 input
(파이썬 2 input
에서는 파이썬 객체 (정수 또는 변수 이름 등)에 대한 사용자 입력을 평가하려고 시도합니다 ... raw_input
사용자 입력을 반환합니다 문자열로)
중히 여기다
>>> apple = 555
>>> print input("Enter Fruit:")
Enter Fruit:apple
555 #returns the value of the variable apple ... if that does not exist you get an error
>>> print raw_input("Enter Fruit:")
Enter Fruit:apple
apple #returns the string "apple"
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다