number = [] for i range(5): number.append(input()) max(number)
number = [] input = open("input.txt", encoding="utf-8").read().split("\n"); input.pop(0) for x in input[0].split(): number.append(int(x)) print(max(number))
number = [] input = open("input.txt", encoding="utf-8").read().split("\n"); input.pop(0) for x in input[0].split(): try: number.append(int(x)) except ValueError: continue try: print(max(number)) except ValueError: print("NaN") finally: pass
import math matrix = [] input = open("input_matrix.txt", encoding="utf-8").read().split("\n"); row_length, col_length = map(int, input.pop(0).split()) for x in input: row = [] for number in x.split(): try: row.append(int(number)) except ValueError: row.append('NaN') matrix.append(row) column_max = [] row_max = [] for i in range(row_length): row = [] for j in range(col_length): if(type(matrix[i][j]) is int): row.append(matrix[i][j]) if(len(row) > 0): row_max.append(max(row)) else: row_max.append("NaN") for i in range(col_length): column = [] for j in range(row_length): if(type(matrix[j][i]) is int): column.append(matrix[j][i]) if(len(column) > 0): column_max.append(max(column)) else: column_max.append("NaN") print(column_max) print(row_max) for i in range(len(column_max)): print("column ", i, " : ", column_max[i]) for i in range(len(row_max)): print("row", i, " : ", row_max[i]) print(max([max([x for x in column_max if type(x) is int]), max([x for x in row_max if type(x) is int])]))
import math del __builtins__.exit matrix = [] input = open("input final.txt", encoding="utf-8").read().split("\n"); row_length, col_length = map(int, input.pop(0).split()) for x in input: row = [] for number in x.split(): try: row.append(eval(number)) except NameError: row.append('NaN') except SyntaxError: row.append('NaN') except ValueError: row.append('NaN') matrix.append(row) column_max = [] row_max = [] for i in range(row_length): row = [] for j in range(col_length): if(type(matrix[i][j]) is int): row.append(matrix[i][j]) if(len(row) > 0): row_max.append(max(row)) else: row_max.append("NaN") for i in range(col_length): column = [] for j in range(row_length): if(type(matrix[j][i]) is int): column.append(matrix[j][i]) if(len(column) > 0): column_max.append(max(column)) else: column_max.append("NaN") print(column_max) print(row_max) for i in range(len(column_max)): print("column ", i, " : ", column_max[i]) for i in range(len(row_max)): print("row", i, " : ", row_max[i]) print(max([max([x for x in column_max if type(x) is int]), max([x for x in row_max if type(x) is int])]))