Skip to content

How to modify the parsing of my Python script

Edit: sample code https://replit.com/@JustinEzequiel/CoralFrighteningSign thanks to JustinEzequiel This is my current code. It outputs something like this (if D32489DJ) was the host name. I want to make it output something like How can I modify my code to make this possible? Snippet of file path all you have …

Truncate sublists to the lowest length

I have: I want: Which is the list l with all sublists truncated to the lowest length found for the sublists in l. I tried: Which works but quite slow and long to write. I’d like to make this more efficient through list comprehension or similar. Answer With list comprehension, one-liner: Or: Output: We c…

Get field type of document field from firestore

Is it possible to get the field type of a field in a document? I want to create a function that looks something like this: Where field.type returns the type of the field. For example it should return something like this: Answer From the document snapshot, with document.get you can get the field value as an Ob…

Python missing data in body

Hello i’m using request to perform some http calls. The is a strange behaviour, the response should contain a list of items, but i only get one item. This is the result i get from Postman when performing the call: With this is the reponse i get in my script : this is how i perform the action : it’…

Nested FOR loops – coding challenge

I am learning python using STEPIK and I am facing this: I want on every iteration of the inside for loop sum the values of predicted_growth list with the value of cases list, save it in some temporary variable and print it. Click on the link for the full challenge. This is my code so far: This is the output

Jupyter import Python function

I have the following folder structure The file foo.py contains In the jupyter notebook I have which gives a file not found error. What’s the cleanest way of fixing that? (If possible, I’d like to keep foo.py unchanged.) Answer You get this error because the path is relative to your working directo…