Ask coding questions

← Back to all posts
husseinovich (1)

I’m made Fibonacci algorithm and everytime it prints the sequence in different lines
Please how can I print all the sequence in the same print line ??
Any ideas?

Answered by Vandesm14 (2256) [earned 5 cycles]
View Answer
Vandesm14 (2256)

You can store each item to an array, and at the end you can join the array and then print it.

Please upvote this if it helped you out 👍

joshwood (116)

Another possible solution would be to out how to print without a newline at the end.
I don't know which language you are using, but in python you can do print("text", end=""). This defines the end token to be an empty string, instead of \n - the default value.