PYTHON: Fill-in-the-Blanks
Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
PYTHON: Fill-in-the-Blanks Program
If you're given a string that has "blanks" (underscores) and an array of words, you can easily fill in the blanks to that string:
Program:
1
2
3
4
5
6
7
8
9
string = "This _ a _ really _ _"
words = ["is", "really,", "long", "string."]
for i in words:
string = string.replace("_", i, 1)
print(string)
Press desired key combination and then press ENTER.
Try it out for yourself, the underscores will be replaced by each word in words.
Feel free to use this code for yourself.
Happy Coding, @Code-Parser
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content