Hi all. I'm taking a beginner python course and have an assignment to write code using a 'for loop' + 'named variable' + 'branching logic'

Trouble is, I have no idea what 'branching logic' is - if anyone has the time to respond, I'd really appreciate it!

branching is just 'which part of the program runs next'. Branches in python are mostly made using 'if', 'elif' and 'else', so for example

a = 10
if a < 5:
  print 'this branch handles case where a < 5'
elif a < 10:
  print 'this branch handles case where 5 <= a and a < 10'
else:
  print 'this branch handles case where 10 <= a'

Thanks so much! Very helpful!

branching is just 'which part of the program runs next'. Branches in python are mostly made using 'if', 'elif' and 'else', so for example

a = 10
if a < 5:
  print 'this branch handles case where a < 5'
elif a < 10:
  print 'this branch handles case where 5 <= a and a < 10'
else:
  print 'this branch handles case where 10 <= a'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.