-2
number=int(input("Input a positive number less than 100:"))
perfect=1
for perfect in range (1,number):
    a=perfect*perfect
    if a >= number:
        break
    print (a)

    

It will output:

Input a positive number less than 100:81
1
4
9
16
25
36
49
64

but It will do these all on a separate line

How do I make it so they all print on the same line?

Community
  • 1
  • 1

2 Answers2

0

Use the end argument in the print function:

print(..., end=" ")
Ethan Bierlein
  • 3,353
  • 4
  • 28
  • 42
0

This is what you are looking for:

print(a, end=" ") # Appends a space instead of a newline
Community
  • 1
  • 1