1

I need to go to line 14 of this code after the code has finished running. How would I do that?

from replit import db
import getpass
import sys

def signup():
    db["User"] = input("Enter username:\n")
    db["Pass"] = getpass.getpass("Enter Password:\n")


def login():
    print("WIP")


LorS = int(input("Login or Signup? (0 for login, 1 for Signup)\n")) # line 14

if LorS == 1:
    signup()
elif LorS == 0:
    login()
else:
    sys.exit()
CrazyChucky
  • 3,263
  • 4
  • 11
  • 25
Yata
  • 13
  • 3
  • 2
    Which line is line 14? What do you mean by "go to" - run the code up to line 14, put the cursor in line 14? At some point, a REPL environment is not good any more and you should use an IDE with debugging capabilities, e.g. PyCharm. – Thomas Weller Jun 28 '22 at 12:04
  • https://stackoverflow.com/questions/15112125/how-to-test-multiple-variables-for-equality-against-a-single-value – Guy Jun 28 '22 at 12:07
  • That last `elif` doesn't need to check against `1` again, the first `if` already did that. – CrazyChucky Jun 28 '22 at 12:09
  • Does this answer your question? [Asking the user for input until they give a valid response](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) – CrazyChucky Jun 28 '22 at 12:12
  • what i mean by "go to" is that i need to, when the current code is finished, run the code again from line 14 – Yata Jun 28 '22 at 12:14
  • Try wrapping lines 14-19 in a `while True` loop – sebtheiler Jun 28 '22 at 12:21

1 Answers1

-1

You loop it and then exit whenever you want to.

from replit import db
import getpass
import sys
def signup():
   db["User"] = input("Enter username:\n")
   db["Pass"] = getpass.getpass("Enter Password:\n")
def login():
   print("WIP")
while True:  # you loop until you want to exit ---------
   LorS = int(input("Login or Signup? (0 for login, 1 for Signup)\n"))

   if LorS == 1:
       signup()
   elif LorS == 0:
       login()
   elif LorS != 1 or 2:
       sys.exit()
Dini
  • 77
  • 1
  • 12
  • maybe i should do a ``` for i in range(2) ``` kind of loop? as i only need to do this twice. thanks for the help :) – Yata Jun 28 '22 at 12:20
  • Why did you change `else` to `elif LorS != 1 or 2:`. Yes, that change will work but the `else`-version is better and something like `variable = 1 or 2` will always be true, even if `variable`has the value `42`. – Matthias Jun 28 '22 at 12:29