Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cant figure this out
#1
x = input("do you have an account yes or no?")
if x != ("yes"):
   quit()
else:
    x = input("what is your username")
    y = input("what is your password")

file=open("usernamepassword.txt","w+")
file.write("Ben McNeill")
file.write("bartisnoob")
file.close()

import random
with open("usernamepassword.txt") as f:
    lines = f.readlines()
    print(random.choice(lines))

if x + y == ("usernamepassword.txt"):
   print("your password and username are correct")
else:
   quit()
It wont compare the file handling to what the input is, any help would be nice.
Reply
#2
if x + y == ("usernamepassword.txt")
if you enter "username" for username and "password.txt" for password than this condition would be True:
otherwise it doesn´t make any sense at all.
You need to compare the contents of variable lines after reading the file with the contents of x and y.
Reply


Forum Jump:

User Panel Messages

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