我目前正在学习Python,所以我不知道正在发生什么。
num1 = int(input("What is your first number? "))
num2 = int(input("What is your second number? "))
num3 = int(input("What is your third number? "))
numlist = [num1, num2, num3]
print(numlist)
print("Now I will remove the 3rd number")
print(numlist.pop(2) + " has been removed")
print("The list now looks like " + str(numlist))
当我运行程序,输入num1、num2和num3的数字后,它返回如下信息:
Traceback (most recent call last):
TypeError: unsupported operand type(s) for +: 'int' and 'str'
str(numlist)
肯定不会导致异常(尽管这可能不是OP想要的)。 - Konrad Rudolph