Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
assigning index
#1
Basicly I have a certain amount of positions (1-3) which can be either True or False.

I want the function I use to get the decent index value.

So
pos1 T
pos2 F
pos3 T
gives indexes 0 and 1

while example below gives 0, 1, 2

and
pos1 T
pos2 F
pos3 F
gives index 0

To me my code feels a bit strange. Lack of knowledge for sure, so what would you suggest?

triggers = [100,200,300]

pos1 = True #never changes
pos2 = True
pos3 = True

Somevalue = 3

pos1 = triggers[0]
if pos2:
    customfunction(a, b, triggers[1])
    if pos3:
        customfunction(a, c,triggers[2])
elif pos3:
	customfunction(a, c, triggers[1])
Reply


Messages In This Thread
assigning index - by 3Pinter - Jan-18-2019, 07:04 PM
RE: assigning index - by Larz60+ - Jan-18-2019, 07:24 PM
RE: assigning index - by nilamo - Jan-18-2019, 07:47 PM
RE: assigning index - by 3Pinter - Jan-18-2019, 08:21 PM
RE: assigning index - by nilamo - Jan-18-2019, 08:44 PM
RE: assigning index - by 3Pinter - Jan-18-2019, 09:57 PM
RE: assigning index - by nilamo - Jan-18-2019, 10:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Assigning a new value to variable uriel 1 1,614 Dec-04-2021, 02:59 PM
Last Post: Underscore
  assigning a variable :( gr3yali3n 0 1,331 Sep-22-2020, 09:02 PM
Last Post: gr3yali3n
  Assigning variables Godserena 4 2,211 Apr-26-2020, 06:59 AM
Last Post: buran
  Assigning a Variable Help MC2020 5 2,962 Jan-06-2020, 10:54 PM
Last Post: MC2020
  Assigning an item from a list xlev 1 1,469 Sep-27-2019, 04:42 PM
Last Post: Larz60+
  Not adding and assigning? 00712411 7 4,227 Oct-10-2018, 07:11 PM
Last Post: volcano63
  Assigning iter_row value to variable ankey 8 9,095 Sep-24-2018, 03:51 PM
Last Post: ankey
  Assigning a new variable in a IF loop pythoneer 5 3,816 Mar-02-2018, 05:21 AM
Last Post: pythoneer
  Assigning to string slice michaeljhuman 1 2,772 Feb-08-2018, 12:57 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020