Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please help coding
#2
This is super ugly, but might help move you in the right direction:
>>> nums = list(map(str, range(1, 10)))
>>> last = None
>>> for row in range(len(nums) + 1):
...   if row > len(nums)/2:
...     row = len(nums) - row
...   if row == last:
...     continue
...   last = row
...   print("." * row, end="")
...   if row:
...     cutoff = row * 2
...     print("".join(nums[:-1 * cutoff]))
...   else:
...     print("".join(nums))
...
123456789
.1234567
..12345
...123
....1
...123
..12345
.1234567
123456789
Reply


Messages In This Thread
Please help coding - by aankrose - May-09-2019, 06:19 PM
RE: Please help coding - by nilamo - May-09-2019, 06:22 PM
RE: Please help coding - by perfringo - May-09-2019, 07:28 PM
RE: Please help coding - by aankrose - May-10-2019, 02:02 AM
RE: Please help coding - by perfringo - May-10-2019, 04:42 AM

Forum Jump:

User Panel Messages

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