我似乎无法让我的.append循环这是我到目前为止所拥有的。我也是while函数。
a = input('options '
'1.add a player'
'2.remove a player'
'3.exit')
player = []
if a == 1: player.append('players name')
答案 0 :(得分:0)
输入返回一个字符串,而不是一个int,所以a将包含类似" 1"的内容。所以在你的if语句中,比较必须是==" 1"。
答案 1 :(得分:0)
在输入函数之后添加“a = int(a)”是解决问题的另一种方法,因此您可以更改“a”的数据类型。
答案 2 :(得分:0)
a = input('options '
'1.add a player'
'2.remove a player'
'3. Print roster.'
'4. name correction'
'5.exit')
player = []
while a == '1':
player.append(input("players name"))
a = input('options '
'1.add a player'
'2.remove a player'
'3. Print roster.'
'4. name correction'
'5.exit')
if a == '2':
player.remove(input("players name"))
a = input('options '
'1.add a player'
'2.remove a player'
'3. Print roster.'
'4. name correction'
'5.exit')
if a == '3':
print(player)
a = input("options enter"
"1.add a player"
"2.remove a player"
"3. Print roster."
"4. name correction"
"5.exit")
if a == '4':
player.remove(input("players name to correct"))
player.append(input('correction'))
a = input('options enter'
'1.add a player'
'2.remove a player'
'3. Print roster.'
'4. name correction'
'5.exit')
答案 3 :(得分:-1)
a = input('options '
'1.add a player'
'2.remove a player'
'3.exit')
player = []
while a == '1':
player.append(input("players name"))
a = input('options '
'1.add a player'
'2.remove a player'
'3.exit')
print(player)