Python Forum
' List[ Conditional statement ] ' What is this code supposed to do.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
' List[ Conditional statement ] ' What is this code supposed to do.
#2
y == yi evaluates to a boolean value (True or False). But bools are actually a subclass of int, so True = 1 and False = 0. So if y == yi, it selects X[1], and if y != yi it selects X[0].

There was a ternary expression added to Python to avoid this sort of code, so that could be rewritten as:

Xi = X[1] if y == yi else X[0]
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: ' List[ Conditional atatement ] ' What is this code supposed to do. - by ichabod801 - Nov-30-2018, 04:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Conditional If Statement: If value contains string then set another column equal to s Jack_Sparrow 2 4,923 Jun-15-2018, 03:33 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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