All Questions
11 questions
-1
votes
2
answers
64
views
How could i append to list any output that my function gives, including errors?
I want to apply my function func to a list of values and collect results. Sometimes it can output errors: JSONDecodeError, IndexError, etc.
A list to which i collect results is result_list. And if ...
0
votes
2
answers
60
views
Simplify multiple functions into one in Python
I am wondering how it is possible to combine the following functions into one. The functions remove the entire word if "_" respectively "/" occur in a text.
I have tried the ...
0
votes
1
answer
42
views
Why is a += b not equivalent to a = a + b here? [duplicate]
I was shocked to find out that a += b behaves differently from a = a + b in my code, and I am able to reduce the issue to the following simple question:
Let's say I have a function g that depends on f ...
0
votes
2
answers
154
views
Edit function code to append results into empty list
I have a function below, where I'd like to append the results of each like into an empty list so that I can call that list outside of the function.
How can I adjust it? Currently there's no error but ...
1
vote
5
answers
2k
views
Making list that takes in value if value appears more than once
If my list has values that appears more than once I want to do the following:
my_list = ['a','b','c','a','a','b']
I want that my_list becomes ['a','b','c']
and at the same time new_list = ['a','a','b'...
0
votes
2
answers
501
views
Why the "NONE" is getting appended in list? [duplicate]
I have made 2 functions: one to generate random values from 0 to 20, and another to check if the value generated by function random matches the value of list. If the value matches then random should ...
0
votes
2
answers
2k
views
Python: Reading line with 'readline()' function and appending to a list
My code:
In my file i have these numbers in a list
charge_account = ['4654145', '9658115', '5658845', '5658045', '6181531', '2134874', '5964554']
I am reading the file with a function, appending it to ...
0
votes
2
answers
149
views
How do I append a variable from a function into a list while looping code in Python
I'm using Python 3 tp scrape price data from a website which results in a variable I named "price". I want to append that data variable into a list I named "pricelist". After the variable is appended ...
0
votes
0
answers
83
views
Append a changing variable to a list and then compare them
I have a Python 3 code that scrapes data from a website which results a single variable called “total”. The variable “total” is a dollar amount. I have code that runs the script every 15 minutes so I ...
-1
votes
1
answer
40
views
Why is this specific function returning 'none'; i'm trying to demonstrate a growing list?
I want to see the list in realtime growing and when its done I want to query the appended list via indices.
l=[]
def GrowingList(list):
try:
import random
while True:
...
0
votes
2
answers
271
views
What does this function need to output?
I'm struggling to figure out exactly what this assignment is asking me to output. I built this python function but it isn't doing what the professor wants it to do. I'm very confused.
Here is the ...