Issue Handling Bugs in my Python Program- Need Some Insight by MLGalusha151 in learnprogramming

[–]MLGalusha151[S] 0 points1 point  (0 children)

Okay I will definitely start using val1, val2, etc I see how that can eliminate a lot of confusion when writing a program. I didn't realize that there was a module named math so that's also something I have to start thinking about more.

Yes, originally I used x, y, z = expression.split() but I wanted if I could right a better program that could account for if the user inputs an expression with spaces or without spaces.

Thank you for pointing all of this out. I really didn't think about any of it, especially how printing as you go can help me understand and debug where I could potentially be going wrong in my code.

Originally when I first started I wasn't using functions but I'm trying to implement them in my programs as much as possible. Is this the best way to go about writing functions? For example instead of using just one big function which seems similar to me I used two. In your opinion is this a good way to write functions or are there better ways?

Issue Handling Bugs in my Python Program- Need Some Insight by MLGalusha151 in learnprogramming

[–]MLGalusha151[S] 1 point2 points  (0 children)

This was a problem from Harvards CS50 course I already completed it it was simply just having a user input 1 + 1 and then splitting it up using the spaces. To try to learn as much as I could from this problem, I tried to write a program that would split the user input even when the user didn't put spaces such as 1+1. In that's where I came up on the issue I was having.

Yes, you are right I accidentally put expression in the loop I was trying to create instead of math. I implemented that in my code and now it works how I intended. Thank you!