If that's the only code you have then, yes, you set (for example) q1 to a value but never use it after that.
If you've failed to show us code outside of those functions that uses q1, it still is not being used.
That's because, if you assign to a variable (like q1 = 42) within a function and that variable is not explicitly marked global, it will be a new local variable within the function, not one already existing in a containing namespace.
So as part of a book I'm working through I'm trying to plot weather data using two different csv files and have implemented a function to do so.
import csv
from matplotlib import pyplot as plt
def get_high(filename, highs):
with open(filename) as f:
reader = csv.reader(f)
header_row = next(reader)
for row in reader:
high = int(row[4])
highs.append(high)
highs = []
get_high('report1.csv', highs)
fig = plt.figure(dpi=128, figsize=(15,9))
plt.plot(highs, c='red')
highs = []
get_high('report2.csv', highs)
plt.plot(highs, c='blue')
plt.title("January Tempatures in Miami 2020(red) vs 1970(blue)", fontsize=20)
plt.xlabel("Days", fontsize=10)
plt.ylabel('Tempatures (F)', fontsize=10)
plt.tick_params(axis='both', major='which', labelsize=16)
plt.show()When I run this it gives me "high = int(row[4]) IndexError: list index out of range".
I've tried going back and changing 4. At 0 and 1 it tells me "ValueError: invalid literal for int() with base 10:" And as soon as I hit the 2nd index (where the integers start) it gives me the IndexError. I noticed when I hover over header_row it tells me that it can't be accessed and I think that's what's causing this problem but I can't find a fix for it.
EDIT; Also looking for a way to make it so the graph DOESN'T start mapping at 0.
"<module_name>" is not accessed Pylance warning when using Conda
Incorrect "variable is not accessed" messages
'module' is not Accessed Pylance(Pylance is greyed out)
"variable" is not accessed when it is used by `locals()`
Videos
That is because VS code detecte that code as dead code which is not going to be used in the program. It will get clearer from the example below:
b = "hello"
def abc():
a = input('enter first number')
return a
abc()
In the example above b is never used, so it is detected as dead code by VS code. VS code refers to these statements as not accessed. But the code assigning the variable will still get executed.
In your case, dealer is not used in the program so VS code finds it as dead code.
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 ;)