I'm trying to complete my code with a main function that should be able to produce an output that looks like this:
consecutive('qqrrb12ss') = True
one_digit('qqrrb12ss') = True
not_nums('qqrrb12ss') = True
length('qqrrb12ss') =True
string_req('qqrrb12ss', old_strings) = True
consecutive('y123bz') = True
one_digit('y123bz') = True
not_nums('y123bz') = True
length('y123bz') = False
string_req('y123bz', old_strings) = False
consecutive('1222345') = False
one_digit('1222345') = True
not_nums('1222345') = False
length('1222345') = False
string_req('1222345', old_strings) = False
consecutive('top89hat') = True
one_digit('top89hat') = True
not_nums('top89hat') = True
length('top89hat') = True
string_req('top89hat', old_strings) = False
My helper functions should be able to do this:
- consecutive: if string has no substring of 3 of the same characters consecutively, returns True
- one_digit: if string has at least 1 digit, returns True
- not_nums: if first and last chars are letters, returns True
- length: string length must be between 8 and 16 for it to return True
- string_req: it's basically all of the other helper functions in one, in addition to ensuring that the new string hasn't been inputted previously
All my helper functions (i.e 'consecutive', 'one_digit', etc.) work perfectly on its own. But I'm having a hard time putting it all together to create this output. Here is what I have so far for the main function:
# Strings used to test function
old_strings = [ 'xyz556677abc', 'top89hat' ]
strings = [ 'qqrrb12ss', 'y123bz','1222345', 'top89hat' ]
def function():
s = strings
L = old_strings
for # I do know I have to use a loop.. But how exactly should I use it?:
print("consecutive", s, "=", consecutive) # should return True or False
print("one_digit", s, "=", one_digit)
print("not_nums", s, "=", not_nums)
print("length", s, "=", length)
print("string_req", s, L, "=", string_req)
Additionally, this is the output I'm getting:
consecutive['aabb12cc', 'a123b', 'a1234546b', 'a1234546b0', 'abcdef1pqrstuvwx', 'abcdef1pqrstuvw', '1222345', 'bat23man'] --> <function consecutive at 0x101d9a950>
one_digit ['aabb12cc', 'a123b', 'a1234546b', 'a1234546b0', 'abcdef1pqrstuvwx', 'abcdef1pqrstuvw', '1222345', 'bat23man'] --> <function one_digit at 0x101d9a9d8>
not_nums ['aabb12cc', 'a123b', 'a1234546b', 'a1234546b0', 'abcdef1pqrstuvwx', 'abcdef1pqrstuvw', '1222345', 'bat23man'] --> <function not_nums at 0x101d9a8c8>
length ['aabb12cc', 'a123b', 'a1234546b', 'a1234546b0', 'abcdef1pqrstuvwx', 'abcdef1pqrstuvw', '1222345', 'bat23man'] --> <function length at 0x101d9a730>
string_req ['aabb12cc', 'a123b', 'a1234546b', 'a1234546b0', 'abcdef1pqrstuvwx', 'abcdef1pqrstuvw', '1222345', 'bat23man'] ['abc112233xyz', 'bat23man'] --> <function string_req at 0x101d9a6a8>