Is there a rationale to decide which one of try or if constructs to use, when testing variable to have a value?
try
if
For example, there is a f
Your second example is broken - the code will never throw a TypeError exception since you can iterate through both strings and lists. Iterating through an empty string or list is also valid - it will execute the body of the loop zero times.