-3

我不明白为什么这是错误的。这令人沮丧,我正在失去耐心......我有截止日期来完成模块并在周日之前完成项目,但我全职工作,我有一个家庭要照顾。我在业余时间一直在拼命想弄清楚为什么这段代码不起作用,这让我感到困惑,因为我无法弄清楚......我在 IDLE 中运行它,它工作得很好,但是每当我在 codio 中运行它时,我都会收到错误“程序输入失败:1,2,3,4,5,6 2 7 预期输出:[1,2,3,4,5,6] 您的程序输出:[ 1、2、6、4、5、70]

您的输出不正确。再试一次。”

# Get our input from the command line
import sys
M= int(sys.argv[2])
N= int(sys.argv[3])

# convert strings to integers
numbers= sys.argv[1].split(',')
for i in range(0, len(numbers)):
  numbers[i]= int(numbers[i])

#I left these comments in so I can remember what values are being plugged in
#print(M) - 5
#print(N) - 3
#print(numbers)
#list2=[1,2,value1,4,5,value2]

for num in numbers:
  if(num == 3):
    #print(M*3)
    value1=(M*3)
    numbers.remove(3)
    numbers.append(value1)
  if(num == 6):
    value2=(N*10)
    numbers.remove(6)
    numbers.append(value2)
    #print(N*10)

mylist=(numbers)
order=[0,1,4,2,3,5]
mylist = [mylist[i] for i in order]
print(mylist)
4

1 回答 1

0
# Get our input from the command line
import sys
M= int(sys.argv[2])
N= int(sys.argv[3])

# convert strings to integers
numbers= sys.argv[1].split(',')
for i in range(0, len(numbers)):
  numbers[i]= int(numbers[i])

# Your code goes here
step = N - 1
while (step<len(numbers)):
  numbers[step] *= M
  step += N
print(numbers)
于 2020-09-25T08:19:58.750 回答