I realize I'm still new to this, but after building my own project from scratch in a proper directory structure and with collaborators, I obviously see the benefits of OOP.
Still, people in tech often say "you read more code than you write", and so you should always try to write code as legibly and clearly as possible, and to that end, I still think procedural programming is way easier to read. Am I just being a little dense here?
To be clear I am not saying "therefore, we should all write ridiculously long scripts instead of neatly structuring modules into subfolders". Just observing that, although I now see why OOP came to be, I am still having difficulty with, say, going from 0 to 1 when it comes time to understanding how a given Python project works. Reading a long bash script is kind of like reading an ordinary book. Getting acquainted with a new project is kind of like reading a Choose Your Own Adventure book, except instead of following one storyline you're trying to follow all threads at once.
So I've been off and on learning python for a while now, and now I'm trying to practice some online assignments (no I'm not in school this isn't me trying to get out of homework) and I'm stuck trying to figure out how to convert my strings to floats.
main function was pre-built for the assignment, all I've done was add the stuff below dollars_to_float and percent_to_float.
Strips are there because assignment said to remove the dollar and percent sign for the print so thats just what i did. sorry if its gross or something to the veterans who may be lurking
EDIT: It is worth noting that float(d) and float(p) likely as well throw errors saying the conversion from string to float can't be done and I've put them in multiple places to no avail.
def main(): dollars = dollars_to_float(input("How much was the meal? ")) percent = percent_to_float(input("What percentage would you like to tip? ")) tip = dollars * percent print(f"Leave ${tip:.2f}") def dollars_to_float(d): float(d) print(d.strip('$')) def percent_to_float(p): float(p) print(p.strip('%')) main()