why can I convert string to integer and then add it to integer❓❓ | Sololearn: Learn to code for FREE!

+1

why can I convert string to integer and then add it to integer❓❓

7/10/2020 8:18:54 AM

Zevil Evil

7 Answers

New Answer

+3

Zevil Evil why don't you try these things on code playground instead of asking it here.

+2

You can do it using int() function.

+2

Zevil Evil Your both examples won't work Ord is used to convert a string character into its equivalent ASCII value

+1

Arsenic What about this:- print(2 + int("sam)) or print(2+int(sam)). Will it work? 𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 And what is ord function?

+1

Arsenic I tried mahn. It didn't work. That's why I was asking? Have I done something wrong or do I need to follow a different concept? btw, thank for the reply!

+1

Zevil Evil it's Ok , no problem Clearly give me sample input & output I'll explain you with that

0

2 examples of converting a string into integer a="12345" b=1122 c=int(a) + b print(c) a="K" b=16899 c=ord(a) + b print(c)