# Something to help those working on the Scientific Computing with Python Budget App

I wrote a function to compare my assembled string for create_spend_chart vs. correct answer in the test module. I hope this helps the person who goes down this rabbit hole of trying to compare the formatted text and find what is wrong!

To use this code, pass your string to chart_check() and you will see output similar to this:

``````You need to remove the very last newline character!
my length: 404 vs. correct length 403
Mine...:Percentage spent by category...
Correct:Percentage spent by category...
Mine...:100|          ...
Correct:100|          ...
Mine...: 90|          ...
Correct: 90|          ...
Mine...: 80|          ...
Correct: 80|          ...
Mine...: 70|    o     ...
Correct: 70|    o     ...
``````

And so on.

Here is the code:

``````    chart_check(return_str)

return return_str[:-1]

# extra code to find mis-matched strings
# copy the 'correct' string from test_module.py

print("You need to remove the very last newline character!")

correct_answer = "Percentage spent by category\n100|          \n 90|          \n 80|          \n 70|    o     \n 60|    o     \n 50|    o     \n 40|    o     \n 30|    o     \n 20|    o  o  \n 10|    o  o  \n  0| o  o  o  \n    ----------\n     B  F  E  \n     u  o  n  \n     s  o  t  \n     i  d  e  \n     n     r  \n     e     t  \n     s     a  \n     s     i  \n           n  \n           m  \n           e  \n           n  \n           t  "

correct_string_split = []
my_string_split = []

# Are they the same length

# Lets look at each line in detail

# check each line to see if they match
if len(correct_string_split) == len(my_string_split):
for line in range(len(my_string_split) ):
print('Mine...:' + my_string_split[line] + '...')
print('Correct:' + correct_string_split[line] + '...')

if my_string_split[line]  == correct_string_split[line] :
#print ("->matching")
pass
else:
print ("ERROR")
print(f"my     length:{len( my_string_split[line] ) } ")
print(f"correct length:{len(correct_string_split[line] )}" )