- 1

As it is in Python

"the database " looks like this. (/t. = Tab key) 12335 /t. Chevy /t. 10000 . . .txt Now I want my program to get a 5 digit input from a user. How do I make the program read the first five digits on the .txt file and output a found and not found output?

4th Feb 2022, 8:12 PM
Ace Brown
Ace Brown - avatar
2 Answers
+ 2
Dear Ace Brown Which programming language are you using? for example, in python you can use this code: number = input('Please enter 5 digit number: ').strip() fileName = input('Please enter file path: ') found = False with open(fileName, 'r') as f: for l in f.readlines(): w = l.split('\t') if w[0].strip()==number: found = True break print("found" if found else "not found")
4th Feb 2022, 8:50 PM
Behzad Soleimani Neysiani
Behzad Soleimani Neysiani - avatar
0
Ace Brown Something like this? txt = "3623457985" user = (input() or "3623486421")[:5] print(user in txt)
4th Feb 2022, 11:27 PM
Rik Wittkopp
Rik Wittkopp - avatar