-1

I am solving the character pattern (Act 1) challenge in Python 3 on SPOJ. I am getting the output but it is not related to sample output.Please check my code for reference:

# your code goes here
n = int(input())
for i in range(n):
    s,t = input().split()
    s,t = int(s),int(t)
    for i in range(s):
        for j in range(t):
            if (i+j) % 2 == 0:
                print("*")
            else:
                print(".")
    print("\n")

I got the following output:

*
.
*


*
.
*
.
.
*
.
*
*
.
*
.
.
*
.
*


*
.
*
.
*
.
*
.
*
.

but the correct output is:

*
.
*

*.*.
.*.*
*.*.
.*.*

*.*.*
.*.*.
Sahil 123
  • 3
  • 6
  • Possible duplicate of [Python: multiple prints on the same line](https://stackoverflow.com/questions/5598181/python-multiple-prints-on-the-same-line) – Caramiriel Aug 25 '18 at 13:07
  • No Sir I didn't want you to solve this problem but I want to know where I am going wrong.Why my pattern is not matching with the sample output – Sahil 123 Aug 25 '18 at 13:08

1 Answers1

0

In Python 3 to print something without new line at the end you need to use the following syntax:

print(something, end="")
Flash Thunder
  • 11,672
  • 8
  • 47
  • 91