I am attempting Problem 20 on Project Euler and this is the solution that I have so far:
import re
mylist = []
var1 = 100
def exclamation(n, L):
for n in xrange(1, (n)):
L.append(n)
n -= 1
print L
def multiply(L, V):
while len(L) > 0:
V = L.pop(-1) * V
print V
exclamation(100, mylist)
multiply(mylist, var1)
print mylist
list1 = re.findall('.', var1)
print list1
However, re.findall only takes strings, and I was wondering if there was something else that did the same job or an escape character to tell it that it is a variable.
I have tried putting a “/” in front of it as well as “/escape” which I think I found on the python documentation, however it didn’t work.
It’s not about whether it’s a variable or not. It’s about whether or not it’s a string. Just make the argument a string. If
var1is an int, this is very easy: