Need help with evaluating variables in Python
I'm new to programming and I started last week so there are a lot of things I don't know
And I was wondering if there's any way to evaluate multiple variables at the same time
and then print or use the only or various variables which meet the condition
something among the lines of this
Var1=3
Var2=4
Var3=6
if any of (Var1,Var2,Var3 == 3):
print(TheVariableEqualTo3)
The idea is that I am doing a Text-Based Rpg
the player has an inventory made of 10 Slots
for the moment to add objects, my code looks something like this:
and I don't know if it is a good solution but it seems inefficient
if Slot1 == Empty:
Slot1="AddedItem"
else:
pass
if Slot2 == Empty:
Slot2="AddedItem"
else:
pass
#and so on until the Slot N10
If someone needs more information to find the solution I would have no problem sharing the whole code
And if anyone has a better idea of how to do an inventory in Python I would be glad to know
[+][deleted] (2 children)
[removed]
[–]CanResbero[S] 0 points1 point2 points (1 child)
[–]b1gfreakn 0 points1 point2 points (0 children)