Skip to content

Instantly share code, notes, and snippets.

@AnnikaNoren
Created August 13, 2020 21:12
Show Gist options
  • Save AnnikaNoren/f4b8c7788fe871266d98a0312162e462 to your computer and use it in GitHub Desktop.
Save AnnikaNoren/f4b8c7788fe871266d98a0312162e462 to your computer and use it in GitHub Desktop.
char_test.py
def char_test(sample):
# Call function to see if there are two numbers that add to 10 in the text string
success = sum_finder(sample)
# Check to see if success (the return is empty or not)
if not success:
print("False")
else:
# These are the two numbers that add to 10
s1 = str(success[0])
s2 = str(success[1])
# print(s1,s2)
# Split the text to a list of char
sample_as_list = split(sample)
# Get indices of the two numbers, make sure they are ints
index1 = int(sample_as_list.index(s1))
index2 = int(sample_as_list.index(s2))
# slice of sample_as_list using the 2 indices
sub_sample = sample_as_list[index1:index2]
# counter of question marks
qm_counter = 0
# Count the question marks in the list slice
for char in sub_sample:
if char == "?":
qm_counter +=1
else:
pass
# Check to see if there are 3 or more question marks between the two numbers
if qm_counter == 3:
print("True")
else:
print("False")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment