Both of strings from userInput
and fcon
matches, it is still unable to print the "matched" message.
I have tried comparing two strings from input()
it work.
userInput = input("First String")
with open("file1", mode ="r") as nameDb:
fcon = nameDb.readline()
print(type(fcon),fcon)
print(type(userInput), userInput)
if userInput is fcon:
print("Matched")
else:
print("No match")
Try it Please,
userInput = input("First String: ")
with open("file1.txt", "r") as nameDb:
fcon = nameDb.readline()
if userInput == fcon:
print("Matched")
else:
print("NO match")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.