'URI Online Judge Problem Fibonacci Series

problem link: https://www.beecrowd.com.br/judge/en/problems/view/1151

why this is not accepted?

n=int(input())
x=0
lst=[]

while True:
    
    if int(len(lst)) == 0:
        lst.append('0')
    elif int(len(lst)) == 1:
        lst.append('1')
    
    else:
        x=int(lst[-1])+int(lst[-2])
        if x>=n:
            break
        else:
            lst.append(x)


result=' '.join([str(elem) for elem in lst])

print(result)


Solution 1:[1]

"print" automatically put "\n" to the end of string. Try use

print(result, end="")

instead of

print(result)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 qazwsxedc