私は引数として送信する2つのリストを空にする関数を呼び出そうとしています。 関数内のリストを空にして、Pythonの元の関数でコードを再利用するようになったら、それらが空であることを確認するにはどうすればよいですか?以下は、私が大規模なシステムでテストを実行する際に使用しているコードです。Pythonで空リストを返す方法
def Input():
nextRound = ['Dad', 'Mom']
maleNames = ['son', 'James', 'Mick', 'Dad']
a = int(input('Enter a number please'))
if a == 1:
ErrorInput(1, nextRound, maleNames)
# I want the below to print two empty strings
print(nextRound, maleNames)
def ErrorInput(error, namelist, round):
if error == 1:
print('ERROR: You have entered a number above what is impossible to
score')
namelist = []
round = []
elif error == 2:
print('ERROR: You Have entered a score meaning both players win')
namelist = []
round = []
elif error == 3:
print('ERROR: You have entered a score meaning neither of the two
players win')
namelist = []
round = []
elif error == 4:
print('EEROR: You have entered a negative number, this is
impossible')
namelist = []
round = []
return(namelist, round)
Input()
あなたのコードがあなたの質問にどのように関係しているかはわかりません。私もあなたがこれをやっている理由を理解していない、明確にすることができますか? –
どちらか分かりませんが、行7を 'nextRound、maleNames = ErrorInput(1、nextRound、maleNames)'に置き換えてください。 –
私は分かりません。 'aList = []' 'aList'というリストを '空にする'のではないですか? – Nae