fill a sequence
Alex Martelli
aleaxit at yahoo.com
Sat Oct 14 05:47:00 EDT 2000
More information about the Python-list mailing list
Sat Oct 14 05:47:00 EDT 2000
- Previous message (by thread): fill a sequence
- Next message (by thread): fill a sequence
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Johannes Zellner" <johannes at zellner.org> wrote in message news:slrn8ufq6k.6ou.johannes at kristine.zellner.org... [snip] > is there somthing like the C++ std::fill() > > e.g. I want to create a sequence of 5 0's > > a = [0, 0, 0, 0] These are just four of them, and you can get this with: a = [0]*4 or, you can get five, with: a = [0]*5 But this doesn't fill the slots of an existing list -- rather, it creates a brand new list. To fill the slots of an existing list, replacing each with 0: for i in range(len(a)): a[i] = 0 Alex
- Previous message (by thread): fill a sequence
- Next message (by thread): fill a sequence
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list