What about converting it to int?

>>>int(a)
100

Just for the sake of completeness, there are many many ways to remove the decimal part from a string representation of a decimal number, one that I can come up right now is:

s='100.0'
s=s[:s.index('.')]
s
>>>'100'

Perhaps there's another one more simple.

Hope this helps!

Answer from Paulo Bu on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › convert float to string without losing precision.
r/learnpython on Reddit: Convert float to string without losing precision.
February 23, 2021 -

I am looking to manipulate a data frame of floats which all need 6 decimal points after manipulation.

I am looking to add brackets and () around the floats based on conditionals which is why I need to convert to strings. I then can concat the two strings together

However when I convert to str, it reduces the number of decimals to 2.

For example

-35.920000 Original Dataframe

Converted to str

-35.92 After conversion

If I convert the string back to a float, it does not retain the 6 decimals from the original df.

My understanding is both values are stored the same and they both are logically = when checked in the notebook , but for management reasons I am trying to see if there is a way to coerce the string method the take a literal copy of the float, rather than reducing it down.

Sorry for the formatting, I am on mobile .

Thanks

🌐
Finxter
blog.finxter.com › python-convert-float-to-string
Python Convert Float to String – Be on the Right Side of Change
March 9, 2024 - If you want to convert a float to a string without the trailing decimal, pass it to the int() function and pass the resulting integer in the str() function.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-remove-all-decimals-from-a-number-using-python
How to remove all decimals from a number using Python? - GeeksforGeeks
July 23, 2025 - By using math.trunc( ) function a number can be truncated in python. ... import math a = math.trunc(450.63) print(a) print(math.trunc(999998.99999)) print(math.trunc(-89.99)) print(math.trunc(0.99)) ... math.trunc(-89.99): Truncates -89.99 to ...
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › python-get-number-without-decimal-places
Remove the Decimal part from a Float in Python | bobbyhadz
April 9, 2024 - You can also use the str.split() method to remove the decimal part from a float. ... Copied!a_float = 3.14 a_list = str(a_float).split('.') print(a_list) integer_part = int(a_list[0]) print(integer_part) # 👇️ 3 ... The str.split() method ...
🌐
Quora
quora.com › How-can-I-convert-a-float-to-a-string-in-Python
How to convert a float to a string in Python - Quora
Answer (1 of 7): # First take any variable and assign any value to it float = 1.2 # Next take another variable(result in this code) # and use python str keyword to convert float value # to str and assign that value to another variable(result in this code) result = str(float) # print the seco...
🌐
py4u
py4u.org › blog › python-precision-in-string-formatting-with-float-numbers
Python Float String Formatting: How to Preserve Full Precision Without Manual Decimal Specification
We’ll cover built-in tools, format specifiers, and advanced modules to ensure your float-to-string conversions are accurate, clean, and adaptable. ... Before diving into formatting, it’s critical to understand how Python stores floats. Python uses binary floating-point arithmetic (per the IEEE 754 standard), which means most decimal fractions (e.g., 0.1) cannot be represented exactly. For example: x = 0.1 print(x) # Output: 0.1 (but internally, it's stored as ~0.1000000000000000055...) When you convert a float to a string, Python may round the value for readability (e.g., str(0.1) returns '0.1').
🌐
AskPython
askpython.com › home › how to format floats without trailing zeros?
How to Format Floats Without Trailing Zeros? - AskPython
May 12, 2023 - from decimal import Decimal ip = Decimal('1.48975480000') The input is then converted into a string using the str( ) function. ... The converted output is passed through the rstrip( ) function within which one ought to specify that the entity ...
🌐
PythonHow
pythonhow.com › how › limit-floats-to-two-decimal-points
Here is how to limit floats to two decimal points in Python
Here is an example of how to use format to limit a float to two decimal points: x = 3.14159265 # Format x as a string with two decimal points y = "{:.2f}".format(x) print(y) # Output: "3.14"The format function takes a format string as the first argument and the value to format as the second argument.
🌐
w3resource
w3resource.com › python-exercises › string › python-data-type-string-exercise-32.php
Python: Print the following floating numbers with no decimal places - w3resource
June 12, 2025 - Write a Python program to print the following positive and negative numbers with no decimal places. ... # Define a variable 'x' and assign it the value 3.1415926 (a positive floating-point number). x = 3.1415926 # Define a variable 'y' and assign it the value -12.9999 (a negative floating-point number).
🌐
Reddit
reddit.com › r/learnpython › how i convert float to string in this case?
r/learnpython on Reddit: How I convert float to string in this case?
August 21, 2022 -

I tried

n1=input('First number')
n2=input('Second number')
sum = float(n1) + float(n2)
str(sum)
print('The sum of the values is: ' + sum)

My error is:

TypeError: can only concatenate str (not "float") to str

I tried googling this error and got some answers like print(f' which I didn't really understand, and some others that looked a little complicated, I am very new.

I am trying to improve my googling skills.

🌐
CoenRaets
jsonviewer.ai › python-float-to-string
Python Float to String [Explained with Code Examples] - JSON Viewer
July 5, 2023 - The format() method is a string method in Python that allows you to format strings by substituting values into placeholders. You can use it to convert a float to a string with specific formatting options. ... # Float to String using format() method float_num = 3.14159 str_num = "{:.2f}".format(float_num) print(str_num) ... In the example above, the float_num variable holds a float value, and the format() method is used to convert it to a string with two decimal places using the :.2f format specifier.