Python place value

Asked 2 years ago, Updated 2 years ago, 38 views

Hello! While making otp with Python, I have a question, so I'm asking you this question!

I want to print out only 6 digits of the algorithm that makes the otp value, but there is a problem with 7 to 9 digits!

So, how can I change the value from 7-8 digits in Python to 6 digits?

python-2.5

2022-09-21 19:35

1 Answers

In a simple way, you can reduce the number of digits through the remaining operations.

ex)

otp = 18573829

new_otp = otp % 1000000
print(new_otp)

Both 7-digit and 9-digit numbers are converted to 6-digit numbers.


2022-09-21 19:35

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.