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.
๐ŸŒ
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.

๐ŸŒ
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).