139k views
4 votes
Print rows and columns (10 points)

Ask the user for how many columns and then how many rows. Then ask the user for what words they like to print. Print those words in the amount of columns and rows the user wanted.

User Deegee
by
4.3k points

1 Answer

4 votes

Answer:

python

Step-by-step explanation:

hi again
im assuming you want this in python because you dont specify this in your question

import random

columns = input('How many columns?\\')

rows = input('How many rows?\\')

columns = int(columns)

rows = int(rows)

list_words = []

inputwords = input('Tell me words you want to print separated by spaces\\')

for word in inputwords.split():

list_words.append(word)

table_data = []

for row in range(rows):

placeholder_column = []

for column in range(columns):

placeholder_column.append(random.choice(list_words))

table_data.append(placeholder_column)

string_of_format = ""

for iter_column in range(columns):

string_of_format += "{: >20}"

for iter_row in table_data:

print(string_of_format.format(*iter_row))

User Alexey Sviridov
by
4.0k points