← Back to Community
Serious help necessary
Profile icon
FARHEENPALAGIRI

Okay so I am trying to write a code where you enter a number, any number, and the program will print the last two digits. So code I wrote basically turns the digits into a big list of strings. Then it finds the length of the list. After that it takes the length of the list and subtracts two. Then it takes the length of the string and subtracts it by the new one. I have absolutely no idea what to do now. Help me please.

a = int(input())
num_list = list(str(a))
str_num = len(num_list))
x = num_list - 2
y = num_list - x

Voters
Profile icon
FARHEENPALAGIRI
Comments
hotnewtop
Profile icon
Geocube101

You cannot subtract an int from a string or a list (Line: 4)
Anyway, I subtracted 2 from 'str_num' and added a for loop to remove the first number in 'num_list'. Once done, the result is joined into a string and printed.
New Code: https://repl.it/@Geocube101/Ask-For-FARHEENPALAGIRI

Profile icon
FARHEENPALAGIRI

I've been working on this for about 2 hours

Profile icon
FARHEENPALAGIRI

OMG thank you so much