0

so I recently started out in python, and I'm looking around the internet for answers. Whenever I copy and paste the following code from a different thread, it always seems to work:

    import os
    import time
    #Must Access this to continue.
    def main():
        while True:
            UserName = input ("Enter Username: ")
            PassWord = input ("Enter Password: ")

            if UserName == 'Bob' and PassWord == 'rainbow123':
                time.sleep(1)
                print ("Login successful!")
                logged()

            else:
                print ("Password did not match!")

    def logged():
        time.sleep(1)
        print ("Welcome to ----")

    main()

It works even when I rename the variables etc etc, however when retyping it myself, I have discovered that no matter what i try it never actually seems to work. This is what I tried:

import os
import time

welcomeMessage = "Welcome to free bitcoin application."

print (welcomeMessage)
time.sleep(1)

#    userName = igoo
#    passWord = b

def begin():

       userName = input("Please enter your username...")
       passWord = input("Please enter your passowrd...")

       if userName == "igoo" or "igor" or "Igoo" or "Igor" and passWord == "b" or "B":
           print: ("Welcome along.")
           logged()

        else:
            print ("Wrong password")
            time.sleep(1)






def logged():
    time.sleep(1)
    print("Alright you in.")

begin()

So any Idea what I'm doing wrong? I've tried several things but none of them seem to work. I understand most people will just shrug it off and say that this is the most simple thing ever and that I shouldn't even bother, but I really want to get this right. I want to continue developing this into a website cloner but only after the login bit, however for now I only wish to finish the login bit.

Any help is much appreciated.

igoo
  • 3
  • 1
  • 4
    What do you mean by not working? Are you seeing any error? Please mention the error too. On the other hand, I've never seen anyone on StackOverflow saying *"this is the most simple thing ever and that I shouldn't even bother"*. Everyone here was once a newbie, and we understand the problems. – Moinuddin Quadri Jan 13 '18 at 09:27
  • indentation defines codeflow for loops, conditions, etc. in python. use either space or tabs (4 spaces preferred) nad indent correctly. Use an IDE that helps you find spacing errors and maybe one that converts tabs to spaces for when you copy/paste code from the web – Patrick Artner Jan 13 '18 at 09:30
  • simplify: `if userName == "igoo" or "igor" or "Igoo" or "Igor"` to `if userName in ["igoo", "igor", "Igoo" , "Igor"]` – Patrick Artner Jan 13 '18 at 09:32

1 Answers1

2

The line if userName == "igoo" or "igor" or "Igoo" or "Igor" and passWord == "b" or "B" in begin() is erroneous.

It should be:

if userName in ["igoo", "igor", "Igoo", "Igor"] and passWord.lower() == "b"

Melvin Abraham
  • 2,870
  • 5
  • 19
  • 33