You want to write a program that reads the text file contents and then receives a string to extract words that end with a specific character 2 that starts with a specific character 1. The text file is read, and I'm lost on what to do next. Can I do this using a regular expression? Or is there another way?
python
There's a lot of ways.
It can be implemented through re-module. I can't explain in detail because I don't know the re-module command properly.
It would be helpful if someone else told me or looked up the re-module regular expression.
If you are simply checking the first letter and the end, you can implement it as follows.
a = 'text'
if a[0] == 'tek' and a[-1] == 't':
print(a)
© 2024 OneMinuteCode. All rights reserved.