SarkariResultess QA Bank

TypeError: unsupported operand type(s) for +: 'int' and 'str' का सही समाधान क्या है? इसका Python best-practice solution क्या है? — error आने पर developer क्या करे?

Other 0 Views Verified
TypeError: unsupported operand type(s) for +: 'int' and 'str' का सही समाधान क्या है? इसका Python best-practice solution क्या है? — error आने पर developer क्या करे?
Sarkari Result QA Bank
Editorially reviewed exam information

Answer & Explanation

4 Answers
Verified Correct Answer

total = 10 + int('5')

total = 10 + int('5')
Additional Explanation
Operands को compatible type में convert करना होगा। पहले traceback की exact line और input value check करें।
Verified

total = str(10) + 5

total = str(10) + 5
Additional Explanation
यह विकल्प सही समाधान नहीं है।
Verified

total = 10 + '5'

total = 10 + '5'
Additional Explanation
यह विकल्प सही समाधान नहीं है।
Verified

total = 10.append('5')

total = 10.append('5')
Additional Explanation
यह विकल्प सही समाधान नहीं है।