How to change the string into an integer ... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to change the string into an integer ...

12th Feb 2021, 12:58 AM
Krishna Singh
Krishna Singh - avatar
5 Answers
+ 7
Specify a relevant language name in the tags ☝ This is something done in variius ways differed by language.
12th Feb 2021, 1:04 AM
Ipang
+ 5
∆BH∆Y I think you meant a = "12345" a = int(a) The OP asked for string to int, not int to string. In Java, what seems to be the only language course you're taking, you can do something like; String n = "12345"; int num = Integer.parseInt(n); // Or Integer num = Integer.valueOf(n) parseInt() will return an value with type int, where valueOf() will return an Integer object.
12th Feb 2021, 2:11 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
As Ipang said, specify the language As in Python, you can do this: a = "12345" a = int(a)
12th Feb 2021, 2:04 AM
∆BH∆Y
∆BH∆Y - avatar
+ 1
ChaoticDawg Oh, I'm sorry I misread the question I made the changes
12th Feb 2021, 3:46 AM
∆BH∆Y
∆BH∆Y - avatar
0
It's correct
12th Feb 2021, 2:41 PM
Krishna Singh
Krishna Singh - avatar