You could just remove the '.' between the digits:

s = '0.0.1'
s = s.replace('.', '')

after that you can make it an int:

int(s)

By making it an integer, you will also remove any leading zeros. If you need a string afterwards just convert it back to string:

s = str(int(s))
Answer from Juergen on Stack Overflow
Discussions

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
September 19, 2015
How to terminate or remove the .0 point from an int.
Try using the g flag when you print it. x = 5.0 y = 5.1 print("regular print:", x, y) print("with g flag:", f"{x:g} {y:g}") More on reddit.com
🌐 r/learnpython
5
2
December 9, 2022
🌐
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
🌐
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.
🌐
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
🌐
Java2Blog
java2blog.com › home › python › how to remove decimals in python
How to Remove Decimals in Python - Java2Blog
October 2, 2023 - Quick Solution To Remove decimals in Python, use int() function.
🌐
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 ...
🌐
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-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.
🌐
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 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.
🌐
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...
🌐
CopyProgramming
copyprogramming.com › howto › python-how-to-remove-decimal-number-using-python
How to Remove Decimal Numbers in Python: Complete Guide 2026 - Remove decimal numbers in python complete guide
December 30, 2025 - For production systems—especially financial applications—Python's decimal module provides exact decimal arithmetic without floating-point errors. from decimal import Decimal, getcontext # Set precision to 28 significant digits (default) getcontext().prec = 28 # Create Decimal from string (NOT float) amount = Decimal('19.99') result = amount.quantize(Decimal('1')) # Round to integer print(result) # Output: Decimal('20') # Financial example: calculate total with tax price = Decimal('99.99') tax_rate = Decimal('0.08') total = (price * (1 + tax_rate)).quantize(Decimal('0.01')) print(total) # Output: Decimal('107.99') — exactly correct
🌐
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 ...
🌐
W3Schools
w3schools.com › python › ref_math_trunc.asp
Python math.trunc() Method
# Import math Library import math # Return the truncated integer parts of different numbers print(math.trunc(2.77)) print(math.trunc(8.32)) print(math.trunc(-99.29)) Try it Yourself » · The math.trunc() method returns the truncated integer ...