Skip to content

[Pere Martin] - lab list comprehension notebook done - #7

Open
perikoloso wants to merge 1 commit into
Ironhack-data-bcn-oct-2023:mainfrom
perikoloso:main
Open

perikoloso wants to merge 1 commit into
Ironhack-data-bcn-oct-2023:mainfrom
perikoloso:main

Conversation

@perikoloso

Copy link
Copy Markdown

No description provided.

@perikoloso perikoloso changed the title lab list comprehension notebook done [Pere Martin] - lab list comprehension notebook done Oct 11, 2023
@bripollc

Copy link
Copy Markdown

Hola Pere,

Muy muy buen lab! Felicidades 🙌🏼 Continua así. Te dejo solo un pequeño detalle:

  • Add a condition to the list comprehension above so that the last value in each subarray is printed, but only if it is less than or equal to 0.5.
list_subarray = [k[-1] for i in b for k in i if k[-1] <= 0.5]
print(list_subarray)

Tu código da correcto pero no está del todo bien planteado porque cuando declaras el statement z == k[-1], estás comparando el valor de z con el tercer valor de la subarray k[-1]. El último valor siempre será el tercero, porque las subarrays solo tienen 3 valores, por lo que es redundante. No sé si me explico... 🫠 La manera de seleccionar el último valor sería usando k[2] o k[-1], sin necesidad de hacer una comparación.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants