Ask coding questions

← Back to all posts
How can i fix this error
Flyingcrabs (7)

Run the code and first type sign up then answer the following question until you get a error. how can i fix this error

Comments
hotnewtop
fedoraguy300 (2)

This is an example.

try:
  number = int(input("Enter a number: "))
  print(number)
except(ValueError):
  print("Invalid Input")

So under the try: you give what you want the program to do. Then if there is an error with that, then it will not shut down but it will do what is in the except:

I put ValueError next to except because I only wanted it to except a value error.

Flyingcrabs (7)

Thanks, I never knew this code line but I don't think this will help @fedoraguy300

fedoraguy300 (2)

@Flyingcrabs all right at least you know now.

Coder100 (15517)

remember to call the function

file.close()
Flyingcrabs (7)

thanks, but not helping with my question @Coder100

Coder100 (15517)

yeah you were having the debugger and I had no way to run it lol @Flyingcrabs

Coder100 (15517)

@Flyingcrabs

look here, as you can see you were set it to the int type. Did you mean to change h to an int?

h = int(h)

there you go

Flyingcrabs (7)

well i tried this not working @Coder100

Coder100 (15517)

well then fix it h is right now ''
'' is not a number @Flyingcrabs

Coder100 (15517)

in fact, why are you even converting it to a number @Flyingcrabs

Flyingcrabs (7)

I wan't to change the # by one @Coder100

Coder100 (15517)

make sure you are adding by str and not int @Flyingcrabs

Flyingcrabs (7)

then i tryied + str(1) there is no error but it only does it between 1 and " (Nothing)" @Coder100

Coder100 (15517)

yeah you set h to be nothing @Flyingcrabs

RYANTADIPARTHI (5835)

it's not allowing me to sign up either. I type sign up, it says invalid syntax.

RYANTADIPARTHI (5835)

@Flyingcrabs try doing this.

file.close
    file=open('password','w')
    h=f
    h=int(h)
    h+=1
    f=str(h)

maybe that will work. Try not using many variables though.

RYANTADIPARTHI (5835)

@Flyingcrabs that's because you are using a str of a file to int. Maybe try using f instead of h.