“Variable” not accessed

We Are Going To Discuss About “Variable” not accessed. So lets Start this Python Article.

“Variable” not accessed

  1. How to solve “Variable” not accessed

    That is because vs-code detect that code as deadcode which is not going to be used in the program.
    It will get more clear from the example below:
    def abc(): a= input('enter first number') b = input('enter second number') return a; alpha = abc(); print(a)
    In the example above, b is never used, so it is detected as deadcode by vs-code. So vs code refer these statements as not accessible.But the code will still get executed.
    In your case , dealer is not used in the program so vs-code finds it as deadcode

  2. “Variable” not accessed

    That is because vs-code detect that code as deadcode which is not going to be used in the program.
    It will get more clear from the example below:
    def abc(): a= input('enter first number') b = input('enter second number') return a; alpha = abc(); print(a)
    In the example above, b is never used, so it is detected as deadcode by vs-code. So vs code refer these statements as not accessible.But the code will still get executed.
    In your case , dealer is not used in the program so vs-code finds it as deadcode

Solution 1

That is because vs-code detect that code as deadcode which is not going to be used in the program.
It will get more clear from the example below:

def abc():
 a= input('enter first number')
 b = input('enter second number')
 return a;
alpha  = abc();
print(a)

In the example above, b is never used, so it is detected as deadcode by vs-code. So vs code refer these statements as not accessible.But the code will still get executed.

In your case , dealer is not used in the program so vs-code finds it as deadcode

Original Author Abhishek Of This Content

Solution 2

The problem is that the value is shuffled in the play again function, but not in the Game() function.

What you probably should do is this:

def PlayAgain():
    again = input("\nDo you want to play again? (Y/N) : ").lower()
    if again == "y":
         Game()
    else:
         print("Bye!")
         exit()

And implement this part in the beginning of your Game() function:

def Game():       
        deck = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]*4
        dealer = []
        hand = []
        random.shuffle(deck)
        #rest_of_your_code

If this does not work you should also share your Game() function 😉

Original Author Bas de Vries Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

ittutorial team

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment