0

stars must be printed at the positions i have used but invalid syntax error is coming

# printing star in a heart shape format
for row in range(0,6):
    for colu in range(0,7):
        if row==0 and colu%3!==0:
            print('*',end=='')
        elif row==1 and colu%3==0:
            print('*',end=='')
        elif row-colu==2:
            print('*',end=='')
        elif row+colu==8:
            print('*',end=='')
        else:
            print(' ',end=='')
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
at K2
  • 3
  • 2

3 Answers3

0

replace if row==0 and colu%3!==0 by

if row==0 and colu%3!=0
Bharath
  • 113
  • 1
  • 1
  • 10
0

As others have said, you need to replace !== with !=. However, you also need to change end== to end=.

Ecko
  • 1,030
  • 9
  • 30
0

This:

if row==0 and colu%3!==0:

Should be like this:

if row == 0 and colu % 3 != 0:

And all of the end==, should be in the form end=

 

So all together:

for row in range(0, 6):
    for colu in range(0, 7):
        if row == 0 and colu % 3 != 0:
            print('*', end='')
        elif row == 1 and colu % 3 == 0:
            print('*', end='')
        elif row - colu == 2:
            print('*', end='')
        elif row + colu == 8:
            print('*', end='')
        else:
            print(' ', end='')
ruohola
  • 21,987
  • 6
  • 62
  • 97
  • While I agree that `!==` should be `!=` and `end==` should be `end=`, it is not strictly necessary to have whitespace in between operators. `if row==0 and colu%3!=0:` is valid syntax, albeit not idiomatically styled. – Kevin Apr 09 '19 at 13:57
  • @Kevin very true, that's why I didn't say that the lack of whitespace was a problem. I just habitually corrected the code to have cleaner whitespace usage. – ruohola Apr 09 '19 at 13:59