متودهای مهم و کاربردی لیستها در پایتون 🐍
#cheatsheet
[🟣, 🟡, 🟣, 🟡].append(🟥) => 🟣🟡🟣🟡🟥
[🟣, 🟡, 🟡].extend([🟥, 🟣]) => 🟣🟡🟡🟥🟣
[🟡, 🟣, 🟥].insert(1, 🟢) => 🟡🟢🟣🟥
[🟡, 🟣, 🟥].remove(🟣) => 🟡🟥
[🟡, 🟣, 🟣, 🟥].pop() => 🟥 [🟡🟣🟣]
[🟡, 🟣, 🟣].pop(1) => 🟣 [🟡🟣]
[🟣, 🟡, 🟥].index(🟡) => 1
[🟡, 🟡, 🟣, 🟡].count(🟡) => 3
[🟥, 🟣, 🟡, 🟡].sort() => 🟡🟡🟣🟥
[🟣, 🟡, 🟡, 🟥].reverse() => 🟥🟡🟡🟣
[🟣, 🟡, 🟣, 🟡].copy() => [🟣, 🟡, 🟣, 🟡]
[🟣, 🟡, 🟡, 🟣].clear() => []
[🟣, 🟡, 🟣].slice(1:2) => 🟡
[🟡, 🟡, 🟣].join(' - ') => 🟡 - 🟡 - 🟣
[🟣, 🟡, 🟡].contains(🟡) => True
[🟡, 🟡, 🟥].rindex(🟥) => 2
👨🏻💻 @Codechee </> کُدچی 🐍
Post #22
122
- ❤ 3