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

input takes a input as string >>> numbers = input(“Enter your numbers followed by commas: “) Enter your numbers followed by commas: 1,2,5,8 >>> sum(map(int,numbers.split(‘,’))) 16 you are telling user to give input saperated by comma, so you need to split the string with comma, then convert them to int then sum it demo: >>> … Read more

Why do ‘and’ & ‘or’ return operands in Python?

I think you’re somehow confused about what the docs says. Take a look at these two docs sections: Truth Value Testing and Boolean Operators. To quote the last paragraph on the fist section: Operations and built-in functions that have a Boolean result always return 0 or False for false and 1 or True for true, unless otherwise stated. (Important exception: the Boolean operations or and and always … Read more