how to loop over the elementary arithmetic symbols
问题 I want to check if 7 digits can get to 100 when putting elementary arithmetic symbols between them. def is_hundred(n1,n2,n3,n4,n5,n6,n7): p = [+,-,*,/] for p1 in p: for p2 in p: for p3 in p: for p4 in p: for p5 in p: for p6 in p: if n1 p1 n2 p2 n3 p3 n4 p4 n5 p5 n6 p6 n7 == 100: return "success" how can i replace the variables with the arithmetic symbols that are in the list? 回答1: In case you didn't hear it: using eval is evil. So that's definitely not code that I'd put in production. That