I’m new to programming a bit, and am learning python so I can learn flask, using the python crash course book. I was learning about list comprehension but it briefly talks about it. If I do

list[list.append(value) for value in range(1, 20)]

it doesn’t work. Would this be some sort of recursive expression that is not possible?

You are viewing a single thread.
View all comments View context
1 point
*

I know I’m being somewhat pedantic but range() returns an iterable range type, not a list, in python 3.

permalink
report
parent
reply
1 point

Not at all. It is indeed helpful to differentiate between an iterable and literal list. After all, sometimes it will bite you in the ass when you don’t differentiate between the two.

permalink
report
parent
reply

Python

!python@programming.dev

Create post

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events
Past

November 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
  • Pythörhead: a Python library for interacting with Lemmy
  • Plemmy: a Python package for accessing the Lemmy API
  • pylemmy pylemmy enables simple access to Lemmy’s API with Python
  • mastodon.py, a Python wrapper for the Mastodon API
Feeds

Community stats

  • 709

    Monthly active users

  • 428

    Posts

  • 2.2K

    Comments