Python Forum
Need to fix SyntaxError in cycle try
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need to fix SyntaxError in cycle try
#1
Hi!
In this block, I need to try all combinations of variables in the ht expression and save only those combinations that ensure the equality of the ht to zero.
I have lists of values for each variable used in expression ht. The variable o is an array whose columns contain interrelated values for 2 variables and that values should to be sorted line by line.

I got a SyntaxError in try (invalid syntax). I also used to change the condition with "try" by using the construction with "if" and "insclose(ht, 0)" instead of "ht == 0", but I get the same syntax error.
Please tell me where this error came from and how to fix it.

for i in z30:
  for o in zres:
    for l in z70:
      def function_gam0(et0, y30, ph0b, o, l):
        ht = o[0] * et0 * cos(i) / sqrt(ph0b) + o[1] * -et0 * sin(i) / sqrt(ph0b) + l * sqrt(1 / ph0b) * et0 * sin(i) + funct_labt(i, o[1], l, o[0]) * (sqrt(1 / ph0b) * (1 + et0 * cos(i) * (1 + et0 * cos(i)**2) / ph0b**2
        try:
          ht == 0
          if True:
            lh0 = i, o[0], o[1], l
            return lh0
            print(lh0)
        except:
          pass
Reply


Messages In This Thread
Need to fix SyntaxError in cycle try - by alexfrol86 - Mar-24-2022, 05:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Writing a cycle to find the nearest point from the array Tysrusko 0 229 May-10-2024, 11:49 AM
Last Post: Tysrusko
  Trying to cycle through a list of charcters pooky2483 12 4,699 Sep-28-2020, 06:55 AM
Last Post: pooky2483
  <while> cycle is not interrupted when using the <random>module ShityCoder 3 2,271 Sep-04-2020, 04:05 PM
Last Post: ShityCoder
  Cycle of numpy variables Zero01 0 1,600 Jul-31-2020, 11:58 AM
Last Post: Zero01
  stop cycle while windows11 1 2,095 May-16-2020, 03:17 PM
Last Post: deanhystad
  Occurrences using FOR and IF cycle P86 2 2,605 Jul-29-2019, 04:37 PM
Last Post: ThomasL
  pool map cycle skorost5 5 3,944 Apr-07-2019, 09:21 AM
Last Post: skorost5
  lifetime cycle counter Ixxxxxx 0 2,540 Mar-07-2018, 07:26 PM
Last Post: Ixxxxxx

Forum Jump:

User Panel Messages

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