Issue
How can I take into account the zeros to the left of the number but still be an int and not a string? I don't want to accept values like 1, 10, 100, 1000... It must be 8 digits like 00000001 or 00015028 (This is just a small piece of the program)
for i in range(size):
CC = int(input("Civil ID: "))
while CC < 000000001 or CC >99999999:
print("Unvalid Civil ID, please insert 8 digits from your Civil ID: ")
CC = int(input("Civil ID: "))
Solution
How about ?
for i in range(size):
input_string = input("Civil ID: ")
CC = int(input_string)
while len(input_string) != 8 or CC < 000000001 or CC >99999999:
print("Unvalid Civil ID, please insert 8 digits from your Civil ID: ")
input_string = input("Civil ID: ")
CC = int(input_string)
Answered By - Take_Care_
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.