Jump to content

highschool help

Jtodd119
Go to solution Solved by mariushm,

not a python programmer and also maybe i'm too tired but isn't this wrong?

 

    while user != "1" or user != "2":

 

or  means if any of the conditions are true, then do what follows

 

so let's say you have

1   user!=1 is false, but user !=2 is true, so false or true = true the result is true

2 user != 1 is true, user !=2 = false ... true or false = true

anything else  : true or true = true

so this happens no matter what input you give, it's infinite loop?

 

why not do whatever python has for a switch statement

 

 

consider changing your login_screen function to do input("username:") and input("password:") only once .... basically put those into a loop and test stuff and put results in a variable ex something like

 

repeat = true

while (repeat== true)

  repeat = false

  name = input("user:")

  pass = input("pass:")

  if name != "something" repeat = true

  ....

end while

// you get here when repeat remains false (all checks passed)

 

 

same for inputstudent function

Hey, Jack here

just checked into ask if someone could help me debug a program I'm creating as part of my gcse Digital technology coursework. Currently stuck on the first function where both a valid and invalid input cause the validation loop to ask for another input.  I was also experiencing a problem where when running the program in the command prompt the program would close its's self while running, even though there were input prompts after the point it kept closing (don't know if this is still a problem due to the the first issue preventing me from retesting it.) 

 

p.s any extra help with refining the program would greatly be appreciated

 

Thanks 

Jack

2nd attempt (at home).py

Link to comment
Share on other sites

Link to post
Share on other sites

Why don't you just copy and paste what you get from the command prompt? Asking question like this doesn't let us know what excatly your problem is. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

not a python programmer and also maybe i'm too tired but isn't this wrong?

 

    while user != "1" or user != "2":

 

or  means if any of the conditions are true, then do what follows

 

so let's say you have

1   user!=1 is false, but user !=2 is true, so false or true = true the result is true

2 user != 1 is true, user !=2 = false ... true or false = true

anything else  : true or true = true

so this happens no matter what input you give, it's infinite loop?

 

why not do whatever python has for a switch statement

 

 

consider changing your login_screen function to do input("username:") and input("password:") only once .... basically put those into a loop and test stuff and put results in a variable ex something like

 

repeat = true

while (repeat== true)

  repeat = false

  name = input("user:")

  pass = input("pass:")

  if name != "something" repeat = true

  ....

end while

// you get here when repeat remains false (all checks passed)

 

 

same for inputstudent function

Link to comment
Share on other sites

Link to post
Share on other sites

On 1/1/2020 at 5:35 AM, wasab said:

Why don't you just copy and paste what you get from the command prompt? Asking question like this doesn't let us know what excatly your problem is. 

theres no error gave out by the command prompt it just keep looping as if the entry was invalid (output shown below)

 

system username = MrWalsh123
system Password = Clarendon814
press enter to continue
welcome to the Clarendon Highschool skitrip
To log in as a Teacher press 1,To complete the student quiz press 21
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz1
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz1
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz1
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz1
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz1
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz2
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz2
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz2
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz22
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz2
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz3
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz3
Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz3

Invalid input, please enter 1 to log in as a teacher or 2 to complete the student quiz4

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×