Unsupported operand type(s) for +: 'int' and 'str'

user3077439

I am currently learning Python so I have no idea what is going on.

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))

When I run the program, entering in numbers for num1, num2 and num3, it returns this: Traceback (most recent call last):

TypeError: unsupported operand type(s) for +: 'int' and 'str'
Ashwini Chaudhary

You're trying to concatenate a string and an integer, which is incorrect.

Change print(numlist.pop(2)+" has been removed") to any of these:

Explicit int to str conversion:

print(str(numlist.pop(2)) + " has been removed")

Use , instead of +:

print(numlist.pop(2), "has been removed")

String formatting:

print("{} has been removed".format(numlist.pop(2)))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

unsupported operand types for //: 'str', 'int'

From Dev

TypeError: unsupported operand type(s) for |: 'int' and 'str'

From Dev

Python - Unsupported Operand Type(s) for -: 'int' and 'str'

From Dev

Unsupported operand type(s) for +: 'NoneType' and 'str' and 'int'

From Dev

TypeError: unsupported operand type(s) for +=: 'int' and 'str'

From Dev

unsupported operand type(s) for /: 'str' and 'int' but different

From Dev

unsupported operand type(s) for +=: 'int' and 'str' on pycharm

From Dev

Python re.compile: unsupported operand type(s) for &: str and int

From Dev

TypeError: unsupported operand type(s) for -: 'str' and 'int' Writing a story?

From Dev

Sum function prob TypeError: unsupported operand type(s) for +: 'int' and 'str'

From Dev

TypeError: unsupported operand type(s) for -: 'str' and 'int' Python

From Dev

python error; unsupported operand type(s) for +: 'int' and 'str'

From Dev

getting error unsupported operand type(s) for +: 'int' and 'str'

From Dev

TypeError: unsupported operand type(s) for +: 'int' and 'str' value

From Dev

Printing highest average - "unsupported operand type(s) for +: 'int' and 'str'"

From Dev

TypeError: unsupported operand type(s) for div: 'str' and 'int' [line 14]

From Dev

Python 3 TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'

From Dev

Python27 TypeError: unsupported operand for type(s) += 'int' and 'str'

From Dev

TypeError: unsupported operand type(s) for /: 'int' and 'str' when making grid

From Dev

Unsupported operand types 'NoneType'

From Dev

Django unsupported operand types

From Dev

unsupported operand types for * : 'float' and 'decimal'

From Dev

averages of numbers in lines of data file "unsupported operand type(s) for +: 'int' and 'str'"

From Dev

Unsupported operand type(s) for +: 'float' and 'str' error

From Dev

TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

From Dev

TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

From Dev

TypeError: unsupported operand type(s) for +: 'Tag' and 'str'

From Dev

Unsupported operand types for bitwise exclusive OR in Python

From Dev

TypeError: unsupported operand type(s) for +=: 'int' and 'list'

Related Related

  1. 1

    unsupported operand types for //: 'str', 'int'

  2. 2

    TypeError: unsupported operand type(s) for |: 'int' and 'str'

  3. 3

    Python - Unsupported Operand Type(s) for -: 'int' and 'str'

  4. 4

    Unsupported operand type(s) for +: 'NoneType' and 'str' and 'int'

  5. 5

    TypeError: unsupported operand type(s) for +=: 'int' and 'str'

  6. 6

    unsupported operand type(s) for /: 'str' and 'int' but different

  7. 7

    unsupported operand type(s) for +=: 'int' and 'str' on pycharm

  8. 8

    Python re.compile: unsupported operand type(s) for &: str and int

  9. 9

    TypeError: unsupported operand type(s) for -: 'str' and 'int' Writing a story?

  10. 10

    Sum function prob TypeError: unsupported operand type(s) for +: 'int' and 'str'

  11. 11

    TypeError: unsupported operand type(s) for -: 'str' and 'int' Python

  12. 12

    python error; unsupported operand type(s) for +: 'int' and 'str'

  13. 13

    getting error unsupported operand type(s) for +: 'int' and 'str'

  14. 14

    TypeError: unsupported operand type(s) for +: 'int' and 'str' value

  15. 15

    Printing highest average - "unsupported operand type(s) for +: 'int' and 'str'"

  16. 16

    TypeError: unsupported operand type(s) for div: 'str' and 'int' [line 14]

  17. 17

    Python 3 TypeError: unsupported operand type(s) for ** or pow(): 'str' and 'int'

  18. 18

    Python27 TypeError: unsupported operand for type(s) += 'int' and 'str'

  19. 19

    TypeError: unsupported operand type(s) for /: 'int' and 'str' when making grid

  20. 20

    Unsupported operand types 'NoneType'

  21. 21

    Django unsupported operand types

  22. 22

    unsupported operand types for * : 'float' and 'decimal'

  23. 23

    averages of numbers in lines of data file "unsupported operand type(s) for +: 'int' and 'str'"

  24. 24

    Unsupported operand type(s) for +: 'float' and 'str' error

  25. 25

    TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

  26. 26

    TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

  27. 27

    TypeError: unsupported operand type(s) for +: 'Tag' and 'str'

  28. 28

    Unsupported operand types for bitwise exclusive OR in Python

  29. 29

    TypeError: unsupported operand type(s) for +=: 'int' and 'list'

HotTag

Archive