How to skip over a environment variable when iterating over them

this is my code:

import os

def main():
  g = input("What's the password?\n")
  if g == os.environ['master-password']:
    for name, value in os.environ.items():
      if name == "master-password":
        break #obviously just ends the program
      else:  
        print("{0}: {1}".format(name, value))
      
main()

I want to skip the master password so it is not revealed.
The reason I want this is that I’m using replit

>Solution :

Use continue instead of break to skip to the next iteration of the loop.

g = input("What's the password?\n")
if g == os.environ["master-password"]:
    for name, value in os.environ.items():
        if name == "master-password":
            continue
        print(f"{name}: {value}")

Leave a Reply