Problem scenario
You want to create a .txt file that has 50 key-value pairs. You want the keys to be whole numbers. You want the values to be five-character strings. What should you do?
Solution
import random
import string
import sys
def randomword(length):
letters = string.ascii_lowercase
return ”.join(random.choice(letters) for i in range(length))
def printer(counter, webstera):
webstera[counter] = randomword(5)
if (counter < …
Continue reading “How Do You Write a Python Program to Create a .txt File with 50 Key-Value Pairs?”