Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

add string to integer in python

a = '123' # This is a string
b = 'love' # This is a string
c = 456 # This is an integer
# 'a' can be converted to an integer but 'b' cannot
print(c + int(a)) # Output - 579
print(c + int(b)) # This will give a Value Error
Source by www.thecodeteacher.com #
 
PREVIOUS NEXT
Tagged: #add #string #integer #python
ADD COMMENT
Topic
Name
8+9 =