Jan-27-2019, 04:14 PM
(This post was last modified: Jan-27-2019, 04:14 PM by RedSkeleton007.)
Hi, I want to print out lock combination guesses, all as 4 digits with leading zeros as needed (0000, 0001, 0002, etc.), but I'm having trouble:
#!/usr/bin/env python3 #MoreOnLoops.py #pad lock guesser lockCombo = 1000 guess = 0000 while guess != lockCombo: guess += 1 if guess == lockCombo: print("After " + str(guess) + " guesses, the correct combo is " + str(guess)) break else: print("{:02d}".format(guess)) #print(str(guess) + " is not the correct combo. Trying next guess.") continueAlso, why is 100 not included in the output of the following loop:
for i in range(5, 100, 5):#start at 5, go up to 100 with increments of 5 print(i)
Output:5
10
15
20
25
30
35
40
45
50
55
60
65
70
75
80
85
90
95