Click here to Skip to main content
15,880,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to access two local arrays to put into a function that calculates based off of them.

The array and variable are:
import random
code=[random.randint(1,9), random.randint(0,9), random.randint(0,9), random.randint(0,9)]

guess=int(input())

The sub-routine is:
def main():
    #creating a function
    answers = [3, 3, 4, 4]
    guesses = [3, 5, 6, 4]

    answers_counter = Counter(answers)
    guesses_counter = Counter(guesses)


The arrays answers and guesses needs to be the first 4 digits in guess and code. How do I access these without getting an error?

What I have tried:

I tried calling the variables and also using global
Posted
Updated 8-Apr-18 22:45pm

1 solution

See my suggestion at your original post of this question: How do I call an array?[^]. If you do not understand how to use parameters in Python modules then see 6. Modules — Python 3.4.8 documentation[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900