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:
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>
You can use it in this way.
for old_s in old_string:
print('consecutive {s} = {ans}'.format(s = old_s, ans = consecutive(old_s)))
print('one_digit {s} = {ans}'.format(s = old_s, ans = one_digit(old_s)))
print('not_nums {s} = {ans}'.format(s = old_s, ans = not_nums(old_s)))
print('length {s} = {ans}'.format(s = old_s, ans = length(old_s)))
for new_s in strings:
print('string_req of {s} and {L} = {ans}'.format(
s = new_s, L = old_strings, ans = string_req(new_s, old_strings)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With