Python code:
import re
with open('line.txt', 'r') as fh:
contents = fh.read()
loop = True
while loop:
user_input = input('Enter a name: ').strip()
if (re.search(r'\b'+ re.escape(user_input) + r'\b', contents, re.MULTILINE)):
print("That name exists!")
else:
print("Couldn't find the name.")
line.txt
albert
robert
No comments:
Post a Comment