convert string to int python

+1 vote

How to convert a numeric string to the corresponding float or integer value in Python?

Apr 15, 2018 in Python by ana1504.k
• 6,110 points
40 views

5 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote

It is pretty simple, consider the example below:
a = '34.44'
c = float(a)

This will convert the numeric string to it's corresponding float value.

answered Apr 15, 2018 by anto.trigg4
• 3,420 points
+1 vote

int() is the Python standard built-in function to convert a string into an integer value. You call it with a string containing a number as the argument, and it returns the number converted to an integer.

answered Oct 18, 2018 by tumharse
+1 vote

You  can understand the working here in this example

print (int("5") + 2)
7


answered Oct 18, 2018 by resut
+1 vote
Instead of putting int( ), put float( ) which will let you use decimals along with integers.
answered Oct 18, 2018 by int-float
+1 vote

Using list comprehensions:

t2 = [map(int, list(l)) for l in t1]
answered Oct 18, 2018 by donald

Related Questions In Python

0 votes
1 answer

Python - convert string to list

try states.split() this would help. READ MORE

answered Jul 20, 2018 in Python by Priyaj
• 56,120 points
33 views
0 votes
1 answer

Python - convert string to list

states.split() will return ['Alaska', 'Alabama', 'Arkansas', 'American', 'Samoa', ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,590 points
37 views
0 votes
1 answer

How to convert date string to date object in python?

Use this :-  >>> datetime.datetime.strptime('24052010 ...READ MORE

answered Oct 22, 2018 in Python by Priyaj
• 56,120 points
41 views
0 votes
1 answer

How to convert an integer to a string using Python?

Here is an easy solution: def numberToBase(n, b): ...READ MORE

answered Nov 23, 2018 in Python by Nymeria
• 3,500 points

edited Dec 12, 2018 by Nymeria 22 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
27 views
+4 votes
7 answers
+2 votes
2 answers

How can I create a new file in Python?

You can try the below code which ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,420 points
43 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.