The Python Learner: SpyGame

So i have decided to learn Python and after reading functions, I was giving the spygame test, I decided not to cheat and try it out … took a little while but I found my own way around it. Before you pros out there Judge me… I am 4 days old in the game so forgive the learners idea ….

CHALLENGING PROBLEMS

SPY GAME: Write a function that takes in a list of integers and returns True if it contains 007 in order

 spy_game([1,2,4,0,0,7,5]) --> True
 spy_game([1,0,2,4,0,5,7]) --> True
 spy_game([1,7,2,0,4,5,0]) --> False

 

And here is my way and results ….Yipee!

I guess i will get better when i learn more about optimizing my Python codes, Hey! at least it works.

Toolbox: Anaconda (Python) & Jupyter Notebook

Tags: , , ,