Python Forum
Help with beginner problem?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with beginner problem?
#2
Use python tags when posting code to preserve the indents, which are important. I added them (and output tags) for you this time. See the BBCode link in my signature below for how to do it yourself.

First, your if statement is wrong. i % 3 or 5 is equivalent to (i % 3) or (5), and 5 is always true. More details are here. You want i % 3 or i % 5.

Note that you don't want to exclude the other rows, you want to print blank rows instead. So you will want an else statement to print the blank row.

The simplest way to add the space in between the asterisks would be i * '* '. You could also do ' '.join(['*'] * i), which wouldn't leave a trailing space. Note that j would have be calculated differently with spaces, since the rows would be wider. Of course, you don't even need j. You can calculate j from i.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Help with beginner problem? - by glkolper - Sep-29-2018, 03:10 AM
RE: Help with beginner problem? - by ichabod801 - Sep-29-2018, 03:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Beginner, problem with CS50 vanity plates problem Chief816 3 6,384 Apr-22-2023, 09:31 PM
Last Post: rob101

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020