Using Python 3.8
I have this function:
Which prints this:
But I need to use a for loop and a join with 3 or 4 spaces to have it print like this:
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
Below is the python program to print .(dot) square of length 5 with 3 spaces between each dot - (change the length variable from 5 to any number and function name is pattern, change it as per your need) (attached the ouput image after the code)
def pattern():
length = 5
for i in range(length):
for i in range(length):
print('.', end = ' ')
print()
pattern();
Output image :
Code image :
Get Answers For Free
Most questions answered within 1 hours.