I want to shorten the lower half of this code into a loop statement.
The only(x) function is an imported function that makes sure 1 to 9 occurs only once.
num_1 = str(raw_input("Enter set 1: ")
num_2 = str(raw_input("Enter set 2: ")
if not only(num_1): ##These two "if not statements" must go in a loop##
print "Error: set 1 is invalid"
if not only(num_2):
print "Error: set 2 is invalid"
So I want the "if not statements" to be in a loop so that the code can be shorter and eliminate repetition.
The new loop however, should be able to print out the error messages with the correct "set number" that holds the error...
My new code as follow, I have created a list called num to try to iterate a loop. I feel like this is not going anywhere and I am right...
num_1 = str(raw_input("Enter set 1: ")
num_2 = str(raw_input("Enter set 2: ")
num = str([(num_1), (num_2)])
###I need to shorten the above code in this spot into a loop statement###