Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (itz_sid):

[Python] My Input Validation is not working properly. It runs through fine, but it isn't returning the data after validating the input.

OpenStudy (itz_sid):

If you look at the screenshot I posted, when I enter the characters number, It does not start the if statement pertaining to that number. It just stops.

OpenStudy (itz_sid):

@518nad

OpenStudy (518nad):

okay so what should be happening right now

OpenStudy (518nad):

attach the code files ill open em

OpenStudy (itz_sid):

Its a huge class file.

OpenStudy (itz_sid):

OpenStudy (itz_sid):

After running the input validation, It should connect to the characters file. So I tested the input validation. I inputted negative numbers, it gave an error message. I inputted garbage letters, it gave an error message. But afterwards, when I input a valid number, it did not open the characters file.

OpenStudy (518nad):

is it only failing if u do the failing check case

OpenStudy (itz_sid):

Yes

OpenStudy (518nad):

i dont see how ur connecting that function back to your character then

OpenStudy (518nad):

u cant just break like that

OpenStudy (itz_sid):

What do you mean? D:

OpenStudy (518nad):

like u have to tie that input back in to the string of functions again

OpenStudy (518nad):

http://prntscr.com/dgbxc6

OpenStudy (itz_sid):

Oh after validating it? how would I do that? I thought since I am returning the value within the Input Validation Class, it automatically connects it with the characters class, just as it does if i dont use input validation.

OpenStudy (518nad):

well

OpenStudy (518nad):

the first choice if its wrong its not going to changing the variable

OpenStudy (itz_sid):

Hm? Does that mean I have to chance value to choice within my input validation?

OpenStudy (518nad):

yeah

OpenStudy (itz_sid):

O

OpenStudy (518nad):

http://prntscr.com/dgbyrb

OpenStudy (518nad):

set choice equal to that line

OpenStudy (518nad):

also not quite sure u actually are setting the new value hes inputting in that function yet but this is a start

OpenStudy (itz_sid):

wait so do i change value to choice or newValue to choice in my input validation?

OpenStudy (518nad):

so do the change i ask u first

OpenStudy (518nad):

then we can fix ur while statement after

OpenStudy (itz_sid):

I did.

OpenStudy (518nad):

okay now check if ur while statement is actually changing anything

OpenStudy (518nad):

before return value put print value

OpenStudy (518nad):

http://prntscr.com/dgc051

OpenStudy (itz_sid):

okay

OpenStudy (518nad):

okay now tell me if its actually changing the value properly

OpenStudy (itz_sid):

OpenStudy (itz_sid):

Thats what i get.

OpenStudy (518nad):

okay so ur value is actually not changing

OpenStudy (itz_sid):

Oh....

OpenStudy (itz_sid):

How would I make it so that it changed? Would I have to put value = NewValue? so that it reverts back to the old variable?

OpenStudy (518nad):

yeaq

OpenStudy (518nad):

or put return newValue

OpenStudy (518nad):

i dont get how that except value error is working there, wont that just cause u to skip through the loop without actually changing

OpenStudy (518nad):

but ya im pretty sure u can figure this out

OpenStudy (518nad):

thats the only problem u got, just make sure ur variable is actually being assigned something, my gf is getting impatient!! i g2g

OpenStudy (itz_sid):

Okay. :/ Thanks

OpenStudy (518nad):

hope u fix it!!

OpenStudy (itz_sid):

@518nad

OpenStudy (itz_sid):

Here is where I am at right now.

OpenStudy (518nad):

ok looks like ur returning the right value lets make sure now

OpenStudy (518nad):

so now ur characterintro is not coming up properly right

OpenStudy (itz_sid):

Yessir

OpenStudy (518nad):

put a print statement under userinpur= lets see if its registered there

OpenStudy (518nad):

i think i know whats going on

OpenStudy (itz_sid):

kay

OpenStudy (itz_sid):

So put print(userInput) under the function call?

OpenStudy (itz_sid):

It prints the 1

OpenStudy (itz_sid):

OpenStudy (518nad):

do print type(userInput)

OpenStudy (518nad):

or just do userInpunt = str(userInput)

OpenStudy (itz_sid):

Is that spelling error suppose to be there?

OpenStudy (518nad):

no lol

OpenStudy (itz_sid):

Oh. YAY IT WORKED! :D

OpenStudy (itz_sid):

THANKS! <3

OpenStudy (518nad):

hahaa okay get to work

OpenStudy (itz_sid):

You are so bae. No homo <3 Lol

OpenStudy (518nad):

hahaa okay just remove all those useless print statements now

OpenStudy (itz_sid):

Yep, done.

OpenStudy (518nad):

just do that next time its good to check everything like that, that was bug checking 101 for u

OpenStudy (itz_sid):

Haha aight. Will do :)

OpenStudy (518nad):

:)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!