r/learnpython • • Feb 29 '20

Actually used python today

I've been learning python for about a month now. I started with automate the boring stuff like so many others have. Since then I have made some small games to practice. I am currently working on a hangman game and needed a list of words to use. I found a list of words and copied the whole thing to a .text file but it came with extra stuff I didn't need. So instead of manually deleting everything I didn't need I made a python script to do it for me. GREATEST FEELING EVER.

393 Upvotes

63 comments sorted by

View all comments

7

u/floridaturtles Feb 29 '20

Could you please share the code? I’m a very very beginner and I have no idea how you could code that

-11

u/mircatmanner Feb 29 '20

Look into regular expressions in python

7

u/rrjamal Feb 29 '20

Just a heads up: regular expressions are a bitch, and just pointless to tell someone to 'look into' when they barely know how to code.

Besides, OP probably just had to get rid of the '/n' or '/b' or something simple at the beginning/end of each line. Just hard coding that removal would more than suffice.

1

u/ScoopJr Feb 29 '20

Regex101 is a good resource. I usually test my strings in here before grabbing the pattern