Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8633481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:29:55+00:00 2026-06-12T09:29:55+00:00

(I mean the Monty Hall problem, this site won’t let me submit something with

  • 0

(I mean the Monty Hall problem, this site won’t let me submit something with ‘problem’ in the title)

I’m attempting to create the Monty Hall problem in python, I thought I had a good plan, but I’m getting the error ‘”NoneType’ object is not subscriptable”. This happens when I try to nest the lists. Does anyone know how I can do this? or fix it?

Thank you.

Here is the code:

car = 0
goat = 0
turns = 0
amount = 100

import random

items = ["New Car", "Goat", "Goat"]
doors = ["Door1", "Door2", "Door3"]

while turns < amount:
    x = random.shuffle(items)
    door = random.shuffle(doors)
    door1 = [door[0], x[0]]
    door2 = [door[1], x[1]]
    door3 = [door[2], x[2]]

    new_list = [door1, door2, door3]

    player_choice = random.randint(0, 2)
    if player_choice == 0:
        print("You have chosen {0}, and behind that is a {1}".format(door1[0], door1[1]))
        if new_list[0][1] == "New Car":
            car += 1
            turns += 1
        else:
            goat += 1
            turns += 1

And then error:

Traceback (most recent call last):
  File "<string>", line 250, in run_nodebug
  File "C:\Programming\Random Programs\Monty Hall Problem.py", line 16, in <module>
    door1 = [door[0], x[0]]
TypeError: 'NoneType' object is not subscriptable
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:29:56+00:00Added an answer on June 12, 2026 at 9:29 am

    random.shuffle doesn’t return a result. It just modifies the list you pass as an argument.

    Perhaps you want something like this?

    random.shuffle(items)
    random.shuffle(doors)
    door1 = [doors[0], items[0]]
    door2 = [doors[1], items[1]]
    door3 = [doors[2], items[2]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I mean something like that: class parentClass { public function method() { echo $this->prop;
I mean something like this: http://www.globalscaletechnologies.com/p-25-sheevaplug-dev-kit-uk.aspx My minimal hardware requirement is: Ethernet card UPDATE:
I mean I have this code: <script> $(document).ready( function() { $('html, body').animate({ scrollTop: $(.error).offset().top
I mean something like: update table_name set field_1=if(date_add(data_field,interval 30 hour) >= now(),1,0), field_2=if(date_add(data_field,interval 30
Is it possible to create multilevel combobox using ExtJS 4.0? I mean, that it
I mean, let's say an User signs up and buy a monthly membership. Is
I'm new to this very useful site... so I would give my thanks to
This is something I've come across twice in the past month and I'm not
I mean I have one line and I want to put 2 spinner in
I mean I can't type from my laptop keyboard into android emulator anymore. Virtual

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.