How to get the length of an integer?
Look, Im trying to create a 3 digit PIN cracker, but I cant even get past the input validation stage as whenever I try to use len(Acc_Code) it always returns 0. This means that no matter the length, it will always continue. Pls help.
Yeah u gotta do this:
Acc_Code = int(34) def change_into_list(string): list_of_string =  list_of_string[:0] = string return list_of_string string_= str(Acc_Code) length = len(change_into_list(string_)) print(length)
This turns the string into a list and gets its' length.
You can just set the variable instead of doing all that globals nonsense. It's already captured by the function closure:
Acc_Code = input("enter code to be cracked")
also you need to set it as a
str, don't type cast to int or else it won't be able to get the length. Only strs have length. Ints don't.
You can use the
len(*object*) function to get the length of an object. For example:
x = 200 y = len(x) print(y)
The output will be: