Skip to content
Sign upLog in
← Back to Community

Python: Taking the number in the tens place

Profile icon
20rduncan

I'm learning Python right now and the program I'm working on is supposed to take the tend digit of a number and print it. My code works, but I can't figure out what to do if there is no tens digit. My code is below.
https://repl.it/@20rduncan/24-Numbers-Tens-digit

Answered by GavHern [earned 5 cycles]
View Answer
Voters
Profile icon
nt-DaayfDaayf1
Profile icon
20rduncan
Comments
hotnewtop
Profile icon
GavHern

You could just say that there is no digit in the tens place.

if len(b) <= 2: print("There is no didget in the tens place.")
Profile icon
Vandesm14

@GavHern
*digit

Profile icon
GavHern

@Vandesm14
I'm surprised how many people correct grammar on here. I don't feel weird for doing it anymore lol.

Profile icon
PYer

@GavHern
Does len() return the length of an integer?

Profile icon
GavHern

@PYer
It will return the digit count. It's usually used for arrays, as I'm sure you know.

Profile icon
PYer

@GavHern
yeah. that's cool. i didn't know it worked on ints though

Profile icon
nt-DaayfDaayf1

tiktok.com/@4_scu

Profile icon
20rduncan

Wow, that was fast. I'll try it out.