Python Forum
[Help] List of Lists not printing both Cmder/Anaconda?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Help] List of Lists not printing both Cmder/Anaconda?
#5
Thank you very much for being so generous, @snippsat! Smile


from pprint import pprint
import random

M = 'land'
o = 'water'
h = 11 #number of rows
w = 11 #number of columns
matrix = []
world = [
         [o,o,o,o,o,o,o,o,o,o,o],
         [o,o,o,o,M,M,o,o,o,o,o],
         [o,o,o,o,o,o,o,o,M,M,o],
         [o,o,o,M,o,o,o,o,o,M,o],
         [o,o,o,M,o,M,M,o,o,o,o],
         [o,o,o,o,M,M,M,M,o,o,o],
         [o,o,o,M,M,M,M,M,M,M,o],
         [o,o,o,M,M,o,M,M,M,o,o],
         [o,o,o,o,o,o,M,M,o,o,o],
         [o,M,o,o,o,M,o,o,o,o,o],
         [o,o,o,o,o,o,o,o,o,o,o]
        ]

def gen_maze():
   rows = []
   for i in range(w):
      matrix.append([])
      col = []
      for j in range(h):
         # matrix[-1].append(0)
         value = random.choice(['o','M'])
         col.append(value)
      rows.append(col)
   return rows

pprint(gen_maze())
[Image: 150818_zpshkfc5afh.png]
Blockchain Visionary & Aspiring Encipher/Software Developer
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube
Reply


Messages In This Thread
RE: [Solved] List of Lists not printing both Cmder/Anaconda? - by vanicci - Aug-15-2018, 03:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  List all possibilities of a nested-list by flattened lists sparkt 1 926 Feb-23-2023, 02:21 PM
Last Post: sparkt
  user input values into list of lists tauros73 3 1,077 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  returning a List of Lists nafshar 3 1,080 Oct-28-2022, 06:28 PM
Last Post: deanhystad
  Creating list of lists, with objects from lists sgrinderud 7 1,665 Oct-01-2022, 07:15 PM
Last Post: Skaperen
Question Printing through list.. again jesse68 2 1,152 Apr-16-2022, 03:24 PM
Last Post: jesse68
  How to efficiently average same entries of lists in a list xquad 5 2,141 Dec-17-2021, 04:44 PM
Last Post: xquad
  sorting a list of lists by an element leapcfm 3 1,891 Sep-10-2021, 03:33 PM
Last Post: leapcfm
  behavior list of lists roym 5 2,116 Jul-04-2021, 04:43 PM
Last Post: roym
  List of lists - merge sublists with common elements medatib531 1 3,417 May-09-2021, 07:49 AM
Last Post: Gribouillis
  help for list printing jip31 8 3,665 May-01-2021, 03:52 AM
Last Post: Pedroski55

Forum Jump:

User Panel Messages

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