2016-08-30 2 views
0

これは私のスクリプトです。私はPythonには初めてですが、これを得るために来ました。答えとして許してください。そして、私が入力した 'あなたが何かをしたいですか' 'yes' にした後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' 
関連する問題