I want to use the while statement below as a def function, what should I do?
i = 0
while True:
i += 1
if i > 5: break
print('*'*i)
And I want to center the result value here.
print("{0:^30}"('*'*i))
If you use it, it's a bit weird. Is there any other way? Contact Us
def python while-statement
The number of stars must be 13 57 9 11 to be centralized.
for i in range(1, 11, 2):
print("{0:^30}".format('*' * i))
*
***
*****
*******
*********
© 2024 OneMinuteCode. All rights reserved.