Public Questions for tag [list]

Ask Question

4 questions


0

Vote

4

Answers

49

View

Given a list ["foo", "bar", "baz"] and an item in the list "bar", how do I get its index (1) in Python?

Jan 20

0

Vote

4

Answers

61

View

I need a good explanation (references are a plus) on Python's slice notation.To me, this notation needs a bit of picking up.It looks extremely powerful, but I haven't quite got my head around it.

Jan 20

0

Vote

4

Answers

28

View

Is there a shortcut to make a simple list out of a list of lists in Python?I can do it in a for loop, but is there some cool "one-liner"?I tried it with functools.reduce():from functools import reduce

Jan 20

0

Vote

5

Answers

31

View

How do I access the index in a for loop like the following?ints = [8, 23, 45, 12, 78] for i in ints: print('item #{} = {}'.format(???, i))I want to get this output:item #1 = 8 item #2 = 23 ite

Jan 18