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?
#1
Hi Python mentors,

I tried running this code:

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

gen_maze()
but it wouldn't run either Cmder or Anaconda Prompt?

It works okay in Jupyter though. Is it because the file ends in .ipynb?

Do you have any idea what's causing this?

Thank you.

==============================================================================
[Image: 00_zpsce01yh8k.png]

[Image: 01_zpsqpwxtmt5.png]
Blockchain Visionary & Aspiring Encipher/Software Developer
me = {'Python Learner' : 'Beginner\'s Level'}
http://bit.ly/JoinMeOnYouTube
Reply


Messages In This Thread
[Help] List of Lists not printing both Cmder/Anaconda? - by vanicci - Aug-15-2018, 12:55 PM

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