|
|
вернуться в форумimport math import re input_string = '' while True: line = input() if line: input_string = input_string + ' ' + line else: break input_digits = [int(x) for x in input_string.replace('\n',' ').replace('\t', ' ').split()] input_digits = input_digits[::-1] for int in input_digits: sqr_root = math.sqrt(int) print(format(sqr_root, '.4f')) #Thanks for the help guys! I tested your code on some online compilers, and the last two answers were printed, but not the first two. It looks like your algorithm correctly read the first line, but because there were empty lines for the next couple lines, your break statement kept the code from reading the last two lines in the example testcase. You need to change the code so it can read all the lines, even the ones that come after empty lines. |
|
|