Skip to content

Python

Python Syntax

print

print("Total Revenue: %f" % total_revenue)
print("Total Revenue: ${f}".format(total_revenue))

List

  • List comprehension
cuts_under_30 = [hairstyles[i] for i in range(int(len(hairstyles))) if new_prices[i] < 30]
  • Get index of element in list

list.index(element)

Try & except

    try:
      some_thing = can_trigger_a_syntax_errror()
    except SyntaxError:
      print("Error caught!")
Back to top