diff --git a/github/funfacts/Spring2022/Kavitha/funfact.txt b/github/funfacts/Spring2022/Kavitha/funfact.txt new file mode 100644 index 00000000..87377dec --- /dev/null +++ b/github/funfacts/Spring2022/Kavitha/funfact.txt @@ -0,0 +1,2 @@ +Kavitha +Not a workout freak but now going for boxing classes \ No newline at end of file diff --git a/python/secret_recipe_decoder.py b/python/secret_recipe_decoder.py index 813f2f7a..2193e381 100755 --- a/python/secret_recipe_decoder.py +++ b/python/secret_recipe_decoder.py @@ -52,20 +52,28 @@ def __init__(self, amount, description) -> None: def decode_string(str): - """Given a string named str, use the Caesar encoding above to return the decoded string.""" - # TODO: implement me - return '1 cup' + Return_String = "" + + for Tmp_char in str: + if Tmp_char in ENCODING: + Return_String = Return_String + ENCODING.values() + + return Return_String + def decode_ingredient(line): - """Given an ingredient, decode the amount and description, and return a new Ingredient""" - # TODO: implement me - return Ingredient("1 cup", "butter") + decoded_line=() + split_line=line.split('#') + for word in split_line: + decoded_line = decoded_line + ( decode_string(word),) -def main(): - """A program that decodes a secret recipe""" - # TODO: implement me + return decoded_line -if __name__ == "__main__": - main() + + +def main(): + with open('secret_recipe.txt', 'r') as Encoded_Recipe: + for line in Encoded_Recipe: + decode_ingredient (line)