2016-08-30 4 views
0

이 스크립트는 제 스크립트입니다. Python을 처음 사용했지만이 문제를 해결할 수있게되었습니다. 답례에서 용서해 주시기 바랍니다. 와 내가 입력 '당신이 무엇을 원하십니까' '예'후Python의 계산기 유형 프로그램에서 오류가 발생했습니다. ValueError

Traceback (most recent call last): 
    File "E:/Python/calculator.py", line 26, in <module> 
    number= int(input()) 
ValueError: invalid literal for int() with base 10: '' 

During handling of the above exception, another exception occurred: 

Traceback (most recent call last): 
    File "E:/Python/calculator.py", line 37, in <module> 
    elif reply--'yes': 
TypeError: bad operand type for unary -: 'str' 

:

import functools 
numbers=[] 

def means(): 
    end_mean = functools.reduce(lambda x, y: x + y, numbers)/len(numbers) 
    print(end_mean) 

def sum(): 
    end_sum = functools.reduce(lambda x, y: x + y, numbers) 
    print(end_sum) 

def whatDo(): 
     print('Input Extra Numbers '+str(len(numbers)+1)+' (or nothing to close):') 
     try: 
      number= int(input()) 
      numbers.append(number) 
     except: 
      print('What do you want to do?') 
      answer = input() 
      if answer == "mean": 
       means() 

while True: 
    print('Input Number '+str(len(numbers)+1)+' (or nothing to close):') 
    try: 
     number= int(input()) 
     numbers.append(number) 
    except: 
     print('What do you want to do?') 
     answer = input() 
     if answer == "mean": 
      means() 
      print('Do you want anything else?') 
      reply=input() 
      if reply=='no': 
       break 
      elif reply--'yes': 
       whatDo() 
     else: 
      break 

그러나 나는이 얻을.

+3

문제는 아주 분명하다 :'== 'yes'' 회신 –

답변

3

elif reply--'yes': 당신은 물론,

elif reply--'yes' 

은 그것이 있어야 오타했다 elif reply == 'yes':

1

해야하는 것은

elif reply=='yes' 
관련 문제