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

  • Home
  • SEARCH
  • 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 7491405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:02:56+00:00 2026-05-29T16:02:56+00:00

import random wordlist = {‘Candy’, ‘Monkey’} level = 0 while level == 0: number

  • 0
import random
wordlist = {'Candy', 'Monkey'}
level = 0
while level == 0:
    number = random.randint(1, 2)
    if number == 1:
        print 'Candy'
        secword = 'Candy'
        level = 2
    elif number == 2:
        print 'Monkey'
        secword = 'Monkey'
        level = 2

for i in secword:
    print i

I have a couple of questions about the code I just randomly wrote (I’m a beginner)

1) How do I assign a word in a list to a variable?
ex. assign the word ‘Candy’ into a variable because I always get the error (List is not callable)

2) How do I assign the variable i (in the for loop) to a separate variable for each letter?

Thanks! Tell me if it’s not specific enough.

  • 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-05-29T16:02:57+00:00Added an answer on May 29, 2026 at 4:02 pm

    It should be pointed out that wordlist is not actually a list, but a set. The difference is that a set does not allow duplicate values, whereas a list does. A list is created using hard-brackets: [], and a set is created using curly-brackets: {}.

    This is important because you can’t index a set. In other words, you can’t get an element using wordlist[0]. It will give you a ‘set does not support indexing’ error. So, before you try to get an element out of wordlist, make sure you actually declare it as a list:

    wordlist = ['Candy', 'Monkey']
    

    I’m not sure what you’re asking in your second question. Can you elaborate?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

import random secret = random.randint (1,99) guess = 0 tries = 0 print (AHOY!
I have the following code: import string import random d =[random.choice(string.uppercase) for x in
For example: import random x = random.randint(1, 6) y = 2 new = x
Here's my code: #This is a game to guess a random number. import random
import random possible = '0123456789abcdefghijklmnopqrstuvwxyz' i = 0 token = '' while i<10: temp
So i have the code: import glob,os import random path = 'C:\\Music\\' aw=[] for
Let's say I have a generator function like this: import random def big_gen(): i
I ran into unbound method error in python with this code: import random class
I am creating a random ID using the below code: from random import *
import java.lang.Math; public class NewtonIteration { public static void main(String[] args) { System.out.print(rootNofX(2,9)); }

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.