Day 12 NuCamp ATM Project
Modules and Packages Debugging / While Loop Practice
Initial start of the project, i couldn’t get my terminal to run my code because of a file issue.
File directory issue — i tried to run a file within a package:
After some research, workshop2 needs to be called first so python knows where to look. I dabbled into some absolute path but my issue was more simply solved:
Once Kenny-Air knew I wanted to access this file through workshop2, i was able to run app.py. I needed to figure this out before starting because i run the terminal to debug — constantly.
Practice — While Loop
This Bitcoin ATM prompts user to register name on this last line.
Limit characters to 10 or less. Also, make sure there ARE characters.
When limiting characters and requiring user to enter the right input, infinite loops with if conditionals I am most comfortable with.
Calling for user input on Line 24 and conditionals on line 25 and Line 27.
Module / Function Problem
On Line 58 the “account” is imported from this module:
The “balance” argument is arbitrary — i could have used:
The essential code here is line 20, returning the amount inputted by the user. I learned the hard way — originally this is how my code looked like:
This caused an an issue with updating my current balance:
Notice that the current balance doesn’t update. I couldn’t figure out the issue until i found out what exactly is my function calling.
I added line 67 to see what exactly i was returning and why it didn’t effect my “current balance”.
So this printed:
Notice that my current balance does not follow the user input or update accordingly. Meaning my function in account.py was executing an operation and does it again when called from app.py, executing with a different variable in ‘current balance’ (Naming important here).
This prompted me to simplify the function in account.py — and manipulate accordingly on app.py (see FINAL CODE).