Python Forum
How to make input come after input if certain line inserted and if not runs OtherCode
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to make input come after input if certain line inserted and if not runs OtherCode
#3
You could loop it.

while True:
    user = input('Username> ')
    if user == 'Myuser':
        passwd = input('Password> ')
        if passwd == 'mypass':
            print(f'{user}, you are now loggerd in')
            break
        else:
            print('Wrong password. Please try again.')
            continue
    else:
        print('Wrong username. Pleasew try again.')
        continue
Adrian_L likes this post
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Messages In This Thread
RE: How to make input come after input if certain line inserted and if not runs OtherCode - by menator01 - Mar-30-2021, 11:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Keep getting "SyntaxError: incomplete input" but can't see why. Pedroski55 3 397 May-14-2024, 07:46 AM
Last Post: gavin34
  Waiting for input from serial port, then move on KenHorse 3 1,248 Apr-17-2024, 07:21 AM
Last Post: DeaD_EyE
  Help with to check an Input list data with a data read from an external source sacharyya 3 506 Mar-09-2024, 12:33 PM
Last Post: Pedroski55
  difference between forms of input a list to function akbarza 6 1,156 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  pyaudio seems to randomly halt input. elpidiovaldez5 2 441 Jan-22-2024, 09:07 AM
Last Post: elpidiovaldez5
  Receive Input on Same Line? johnywhy 8 845 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  manually input data jpatierno 0 372 Nov-10-2023, 02:32 AM
Last Post: jpatierno
  Using string input for boolean tronic72 3 765 Nov-01-2023, 07:48 AM
Last Post: Gribouillis
  problem in using input command akbarza 4 1,259 Oct-19-2023, 03:27 PM
Last Post: popejose
  problem in entering address of a file in input akbarza 0 693 Oct-18-2023, 08:16 AM
Last Post: akbarza

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020