Poor-Effort Conversation
Student gives incomplete responses and poor explanations
Good-Effort Conversation
Student gives thoughtful explanations and shows their understanding
ddb

Quack. I am CS50's duck debugger (ddb), an experimental AI for rubberducking. Quack quack. My replies might not always be accurate, so always think critically and let me know if you think that I've erred. Conversations are logged. Quack quack quack.

ddb

Quack. I am CS50's duck debugger (ddb), an experimental AI for rubberducking. Quack quack. My replies might not always be accurate, so always think critically and let me know if you think that I've erred. Conversations are logged. Quack quack quack.

you

my code isn't working to find the largest row

data_rows = get_collision_data()

largeval = None
for row in data_rows:
    column = 'Collisions per billion miles'
    if largeval == None or row[column] > largeval[column]:
        largval = row

print(largval)
you

my code isn't working to find the largest row

data_rows = get_collision_data()

largeval = None
for row in data_rows:
    column = 'Collisions per billion miles'
    if largeval == None or row[column] > largeval[column]:
        largval = row

print(largval)
ddb

It looks like you're trying to find the row with the largest value in a specific column. Can you tell me more about what's not working? Are you getting an error message, or is the output not what you expect?

ddb

It looks like you're trying to find the row with the largest value in a specific column. Can you tell me more about what's not working? Are you getting an error message, or is the output not what you expect?

you

no errors

you

No error message. The output is always just the last row in my data

ddb

Great, no errors is a good start! Let's look at the logic together. You mentioned that your code isn't working to find the largest row. What is the output you're getting, and how does it differ from what you expect?

ddb

It sounds like the issue might be with the condition in your if statement. Can you walk me through your logic there?

you

it prints the wrong row

you

I check if largeval is none to set it on the first pass of the loop. Then I check if largeval is smaller than the row to update it if I find a row with a larger value

ddb

Let's look at the logic in your code. You're comparing the current row's value to the largest value found so far. Do you see any potential issues with this comparison?

ddb

Your logic seems sound! Let's take a closer look at the code. I noticed a small typo in your code. Can you spot it?

you

no, help me

you

I tried but no

ddb

No problem! Let's go through the comparison step by step. In your code, you're comparing the current row's value to the largest value found so far. How are you storing the largest value found so far?

ddb

No worries! Let's look at the code together. In your if statement, you compare largeval to the current row. But in the line where you update largeval, you accidentally wrote largval instead. Do you think this could be causing the issue?

you

in largeval

Result: Bug found! Describing the specific symptom ("always the last row") and explaining the logic gave the duck enough context to immediately zero in on the typo: largval instead of largeval.
ddb

Great! You're storing the largest value found so far in largeval. Now, let's look at the comparison. How are you comparing the current row's value to largeval?

Result: Bug never found One-word answers gave the duck nothing to work with. After many back-and-forth exchanges, the conversation kept going in circles and the bug was never identified.