Can i have help in coding my pokemon game?

when starting my code it doesnt reset all pokemon caught it is stuck at one
Repl link:

import sqlite3

# connect to the database
conn = sqlite3.connect("pokemon.db")

# reset the counts for all caught pokemon to 0
conn.execute("UPDATE caught_pokemon SET count = 0")

# commit the changes

# close the connection
1 Like

Looking at your code, I see the following issues:

  1. While not going to cause a crash, you don’t need to import sqlite3 and initialize the database twice.
  2. The command you’re calling to reset is not going to work as expected here, you need to (AFAIK) set each key to 0 in the Database using a for loop or something similar.
1 Like

i removed the code import sqlite3 but it still wants the command but i cant remember it do you?

1 Like

Which import did you remove? It was imported twice, and only the lower one of the two should have been removed.

i removed the first import

and deleted one or two initalizeents

That will cause an error, because you call sqlite3 before it is defined now. Please put the import back at the top, and remove the one below the get_shiny_chance function.

i removed the get_shiny_chance for now and i dont know how to define sqlite3


Put the import sqlite3 line back at the top of your code.

import sqlite3 is back and now when running the code says line 20 is wrong and indentationError: unxepected indent. but i dont know why

Line 20 is incorrect because it is indented when the program did not expect it. That line, and through line 26 can all be removed, as you removed the function that was using those lines.

Also, you still have an extra sqlite3 import on line 30.

should i remove all in betwen 20-26?

Since you already removed the function that was using them, you might as well. Alternatively you could just comment those lines out for now (start the lines with a #)

conpletely removed it now says line 25 is wrong for closed database

Since you close the database on line 10, subsequent writes will fail, as would any write after line 63. Try removing or commenting out lines 10 and 63.

how to comment out “i am really new to python code”

As I mentioned in my previous post, all’s you have to do to comment out line(s) is:

should i also comment out line 25? as it is the same commanda as code says problem with same line

I made a mistake, I meant to say to remove/comment 13, but I said 10. I apologize.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.