+ 2
hey how can convert a='45' to b = 45
8 Respostas
+ 17
a = '45'
b = int (a)
+ 4
Nope you will get an int number
a = '45' #single quotes makes it string so a is string
now we will convert a from string to int
b = int (a)
You will get an int
b = 45
----------------
You will get ascii number if you use this function "ord"
Print ("A = ", ord("A"))
Output will be
A = 65
+ 1
You are Welcome :)
+ 1
use b= int(a)
+ 1
you have to cast the argument to convert a string to integer.
b=int (a)
0
thanks for your information
0
here, when a='45' means that a has a string stored in it.
to convert a string '45' to an integer 45 and to store it in a variable b ,we assign a variable b as an integer and copy the value of a to b.
here typecasting occurs.
b=into(a)
- 2
i will not get it as b= 45.
instead i might get b= some ascii number in related with '45' in int datatype