You are viewing a single comment's thread. Return to all comments →
I am confused about why this is not working. If anyone can help I'll apreceate.
import math import os import random import re import sys if __name__ == '__main__': first_multiple_input = input().rstrip().split() n = int(first_multiple_input[0]) m = int(first_multiple_input[1]) matrix = [] for _ in range(n): matrix_item = input() matrix.append(matrix_item) text = '' for j in range(m): for i in range(n): if j < len(matrix[i]): text += matrix[i][j] else: text += ' ' result = '' i = 0 while i < len(text): if text[i].isalnum(): result += text[i] i += 1 elif text[i].isspace(): result += text[i] i += 1 else: next_alnum = i + 1 while next_alnum < len(text) and not text[next_alnum].isalnum(): next_alnum += 1 if (i > 0 and text[i-1].isalnum() and next_alnum < len(text) and text[next_alnum].isalnum()): result += ' ' i = next_alnum else: result += text[i] i += 1 if result.strip() and result.strip()[0] == '#': result = result.rstrip() + ' @' print(result)
Seems like cookies are disabled on this browser, please enable them to open this website
Matrix Script
You are viewing a single comment's thread. Return to all comments →
I am confused about why this is not working. If anyone can help I'll apreceate.