1 / 4
Aug 2016

indent preformatted text by 4 spaces
n = int(raw_input(""))
lines = []
column = []
i = 0
while i < n:
var1, var2 = raw_input("").split()
lines.append(var1),
column.append(var2)
i += 1

i = 0
while i < n:
temp = int(lines[i])
temp1 = int(column[i])
j = 1
while j <= temp:
k = 1
if j % 2 == 0:
while k <= temp1:
if k % 2 == 0:
print ".",
else:
print "*",
k = k + 1
else:
while k <= temp1:
if k % 2 == 0:
print "*",
else:
print ".",
k = k + 1
print ""
j = j + 1
print ""
i = i + 1

What's wrong with code?

  • created

    Aug '16
  • last reply

    Aug '16
  • 3

    replies

  • 684

    views

  • 2

    users

When posting code (especially Python code which absolutely requires proper indentation), make sure it is correctly indented. If you do that, I'll find you an input which gives you WA.

n = int(raw_input(""))
lines = []
column = []
i = 0
while i < n:
    var1, var2 = raw_input("").split()
    lines.append(var1)
    column.append(var2)
    i += 1

i = 0
while i < n:
    temp = int(lines[i])
    temp1 = int(column[i])
    j = 1
    while j <= temp:        
        k = 1    
        if j % 2 == 0:
            while k <= temp1:
                if k % 2 == 0:
                    print "*",
                else:
                    print ".",
                k = k + 1 
        else:
            while k <= temp1:
                if k % 2 == 0:
                    print ".",
                else:
                    print "*",
                k = k + 1 
        print ""        
        j = j + 1
    print ""    
    i = i + 1

Please let me know where I am making mistake here.

You are printing spaces after characters.

Input
1
3 3

Correct output:
*.*
.*.
*.*

Your output:
* . *
. * .
* . *

Also, you print an endline after the last case. The statements says to print endlines in between cases, which would imply not after the last one.