“You need to organize your programming so that you have lots of little successes.”
“Get something working and keep improving it”
When debugging, every thing is a suspect except Python.
int
object to a str
objectstr
object as a parameter, but it receives a float
objectActivity 1: Consider the code shown below. The first line defines a list with variable name “items.” Note that the list consists of objects of different type. This IS valid. Can you identify the type of error within this program? Type the program in an active code window to verify the error type. Then, fix the bug so the program runs correctly.
items = [1, 2.3, 'orange', 'True', 3.1415, pink, "apple"]
for item in items:
print(type(item))
Activity 2: Use the corrected list from the previous Activity, but remove the quote marks from the ‘True’ item. Will this cause an error? Run the program to find out.