Closed Almenon closed 3 years ago
it also fails on break
# test program copied from https://www.programiz.com/python-programming/examples/prime-number
num = 407
# take input from the user
# num = int(input("Enter a number: "))
# prime numbers are greater than 1
if num > 1:
# check for factors
for i in range(2,num):
if (num % i) == 0:
print(num,"is not a prime number")
print(i,"times",num//i,"is",num)
break # <- FAILS HERE: File "<string>", line 1
else:
print(num,"is a prime number")
# if input number is less than
# or equal to 1, it is not prime
else:
print(num,"is not a prime number")
fails on continue too (see previous example, just replace break with continue)
Awesome! Okay man, I'm busy for the next bit but I'll have those fixed up soon as I can after.
Hmm, funny that pass and continue break it.. I've got a mighty cryptic regex that should just ignore those keywords..
Anyways, thanks for breaking em up too. Cheers :beers:
yeah... the regex is so long it times out on regex101 XD
https://regex101.com/r/sf6nAH/15
BTW you can break regex up into multiple lines and add comments, like so:
import re
WOLF_MACROS = re.compile(r"""
\w # we want to capture word because bla bla bla
\d # then number because bla bla bla
""", re.VERBOSE) # verbose ignores comments and whitespace
(Trey Hunner gave a talk to SD python about this recently)
And at some point you probably want to break some of the regex logic out into functions or seperate it out into multiple regexes.