sorry if this is the wrong place for this question or anything. I picked up a book on python and I'm trying to learn the basics by myself right now. My question is, if I'm given two different numbers, is there a way I can find the tens and ones digit of both numbers, regardless of the length of each number? How would I go about doing this? I'm trying to use floor division and modulo because that makes sense but I can't get it quite right. In the future, how should I approach things like this? Thanks so much!
Modulo and floor division is probably the best way to go for large numbers:
num = 1327419832467138974619485762453
# Tens
print(num % 100 // 10)
# Ones
print(num % 10)
Output:
5
3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.