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
🌐
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)

🌐
GeeksforGeeks
geeksforgeeks.org › how-to-remove-all-decimals-from-a-number-using-python
How to remove all decimals from a number using Python? - GeeksforGeeks
March 27, 2025 - A gnboorse-rom module is that library of python which helps you convert roman numerals into decimal number and decimal number into roman numerals .It will do conversion of values upto 3999 both in roman numerals and decimal system . Note: Following is the list of some unique Roman symbols with their ... When working with data in R Programming Language, especially text data, there might be situations where you need to clean up strings by removing all non-numeric characters.
🌐
Javatpoint
javatpoint.com › how-to-remove-decimal-in-python
How to Remove Decimal in Python - Javatpoint
Python bit functions on int(bit_length,to_bytes and from_bytes) Check if String has Character in Python · How to Get 2 Decimal Places in Python · How to Get Index of Element in List Python · Nested Tuples in Python · GUI Assistant using Wolfram Alpha API in Python ·
🌐
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. ... Please note that when we remove decimal places, number before decimal point(.) will remain the same.
🌐
Bobby Hadz
bobbyhadz.com › blog › python-get-number-without-decimal-places
Remove the Decimal part from a Float in Python | bobbyhadz
April 9, 2024 - The math.trunc method takes a number, removes its fractional part and returns its integer part. The math.trunc() method rounds towards zero. ... Formatted string literals (f-strings) let us include expressions inside of a string by prefixing ...
Find elsewhere
🌐
ItSolutionstuff
itsolutionstuff.com › post › python-remove-all-decimals-from-number-exampleexample.html
Python Remove All Decimals from Number Example - ItSolutionstuff.com
October 30, 2023 - Today, python remove all decimals from number is our main topic. we will help you to give an example of how to remove decimal point from a number in python. If you have a question about how to remove decimal from a number in python then I will give a simple example with a solution. If you have a question about how to remove decimal places in python then I will give a simple example with a solution.
🌐
Python Guides
pythonguides.com › remove-decimal-numbers-in-python
Remove Decimal Numbers in Python
September 2, 2025 - We can remove decimal places in Python using the trunc() function from the math library.
🌐
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 in PythonChecking if a number is divisible by another number in PythonHow to check if a NumPy array has all zeros in PythonHow to get a current year in PythonHow to remove multiple spaces from a string in Python
🌐
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...
🌐
YouTube
youtube.com › codeinvite
python remove decimal places - YouTube
Download this code from https://codegive.com In Python, you may need to format or remove decimal places from a numeric value for various reasons. This tutori...
Published   December 24, 2023
Views   34
🌐
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
🌐
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 ...
🌐
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
🌐
datagy
datagy.io › home › python posts › python strings › python: truncate a float (6 different ways)
Python: Truncate a Float (6 Different Ways) • datagy
April 14, 2024 - For this, we can easily use string formatting by way of the helpful f-string features in Python. With this, we can specify the number of decimal points to keep and convert the string back to a float.