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
๐ŸŒ
Replit
replit.com โ€บ home โ€บ discover โ€บ how to remove the decimal in python
How to remove the decimal in Python | Replit
March 3, 2026 - The f-string format specifier :.0f tells Python to display a number with zero decimal places, which also rounds it to the nearest whole number. The expression f"{num:.0f}" rounds 42.75 to 43. It's important to note that the result is a string (str), not a number. This makes the technique ideal for formatting output for display, but not for further mathematical calculations. from decimal import Decimal, ROUND_DOWN num = Decimal('42.75') no_decimal = num.quantize(Decimal('1.'), rounding=ROUND_DOWN) print(f"Original: {num}, Without decimal: {no_decimal}")--OUTPUT--Original: 42.75, Without decimal: 42
Discussions

How to remove decimals in float?
If this is just for printing... f'{my_float:.6f}. If you actually need that level of precision, you're likely to run into rounding issues, but you could try something like this: int(my_float * (10**6)) / (10**6) More on reddit.com
๐ŸŒ r/learnpython
18
9
April 15, 2023
Int to String without decimal points?
Hey guys, Iโ€™ve made a function to get the dimensions of my bounding box and iโ€™m putting them into a sentence as a string by using str(varx)+srt(vary) etc. I have even rounded the Integers by using Round() but when i turn them into strings, everything comes up with 1 decimal precision thatโ€™s ... More on discourse.mcneel.com
๐ŸŒ discourse.mcneel.com
6
0
April 20, 2023
Python: Remove division decimal - Stack Overflow
I have made a program that divides numbers and then returns the number, But the thing is that when it returns the number it has a decimal like this: 2.0 But I want it to give me: 2 so is there an... More on stackoverflow.com
๐ŸŒ stackoverflow.com
July 15, 2013
integer - Python how to remove decimal? - Stack Overflow
I've found some other topics on this but I couldn't get it to work. Please pardon my naivety with Python. Berekening1 = 8.5 Berekening2 = 8.1+4.8 Berekening3 = 8*10 Berekening4 = 3 x = Berekening1 * More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
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 ...
๐ŸŒ
Javatpoint
javatpoint.com โ€บ how-to-remove-decimal-in-python
How to Remove Decimal in Python - Javatpoint
How to Remove Decimal in Python with python, tutorial, tkinter, button, overview, entry, checkbutton, canvas, frame, environment set-up, first python program, operators, etc.
๐ŸŒ
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 math.ceil() method to remove the decimal part from a float by rounding up.
Find elsewhere
๐ŸŒ
Reactgo
reactgo.com โ€บ home โ€บ how to remove decimal part from a number in python
How to remove decimal part from a number in Python | Reactgo
April 19, 2023 - The int() method takes the number as an argument and returns the integer by removing the decimal part from it. ... It can be also used with negative numbers. ... How to reverse a tuple in Python (2 Easy ways)How to get last n elements of a list ...
๐ŸŒ
Java2Blog
java2blog.com โ€บ home โ€บ python โ€บ how to remove decimals in python
How to Remove Decimals in Python - Java2Blog
October 2, 2023 - The math library is used in Python to provide functions and constants that can calculate complex mathematical calculations. We can remove decimal places in Python using the truncate() function from the math library.
๐ŸŒ
Quora
quora.com โ€บ How-can-I-remove-numbers-more-than-2-decimal-places-in-string
How to remove numbers more than 2 decimal places in string - Quora
Answer (1 of 3): Well, you could first convert it to a numeric value, round it off, and then change it to a string again. If that is infeasible for some reason, there is another thing you could try. Take the value of position of the decimal point (x = string.indexOf('.') in javascript) and then t...
๐ŸŒ
Python
docs.python.org โ€บ 3.4 โ€บ library โ€บ decimal.html
9.4. decimal โ€” Decimal fixed point and floating point arithmetic โ€” Python 3.4.10 documentation
Construct a new Decimal object based from value. value can be an integer, string, tuple, float, or another Decimal object. If no value is given, returns Decimal('0'). If value is a string, it should conform to the decimal numeric string syntax after leading and trailing whitespace characters are removed...
๐ŸŒ
ItSolutionstuff
itsolutionstuff.com โ€บ post โ€บ python-remove-all-decimals-from-number-exampleexample.html
Python Remove All Decimals from Number Example - ItSolutionstuff.com
October 30, 2023 - If you have a question about how to remove decimal places in python then I will give a simple example with a solution. There are several ways to remove all decimals from number in python. i will give you simple one example to remove decimal point from a float.
๐ŸŒ
Python Guides
pythonguides.com โ€บ remove-decimal-numbers-in-python
Remove Decimal Numbers in Python
September 2, 2025 - For each element in decimal_value, it converts it to a string (str(each)). ... You can see the output in the screenshot below. Splits it at the decimal point (โ€˜.โ€™), then appends the part before the decimal point to a list called empty_list. This is another way to remove decimal numbers in Python using the %d placeholder.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how to terminate or remove the .0 point from an int.
r/learnpython on Reddit: How to terminate or remove the .0 point from an int.
December 9, 2022 -

Hello everyone,

I am still new to python and learning.

So I practiced some exercises and made an app that calculates the percentage from the number the user enters.

My question use, how can I terminate the .0 part if the user enters an Int and keep the decimal part if they enter a float?

so for example, 5% of 100 is 5 ( Int)

and 5.1% of 100 is 5.1 (float)

๐ŸŒ
Python Guides
pythonguides.com โ€บ remove-decimals-from-a-string-in-python
Remove Decimals from a String in Python
September 3, 2025 - We can use regular expressions to remove decimal parts in Python from strings by matching the pattern of numbers with decimals and extracting the integer part.
๐ŸŒ
Saturn Cloud
saturncloud.io โ€บ blog โ€บ how-to-remove-decimal-points-in-pandas-a-guide-for-data-scientists
How to Remove Decimal Points in Pandas A Guide for Data Scientists | Saturn Cloud Blog
December 23, 2023 - These methods include using the round() function, the astype() function, the apply() function with a lambda function, and the floor() function. By implementing these methods in your code, you can effectively remove decimal points from your data ...