All Questions
1,917 questions
0
votes
2
answers
32
views
TCL - A condition for an item while appending items to a list
I have this list
set csv [list]
lappend csv [list \
a \
b \
c \
[expr {[cfg::get enable_all_columns]
? {
d
}
: {}
}] \
e \
f \
g]
I need to add element d only if enable_all_columns is 1. The problem ...
2
votes
1
answer
51
views
How can I delete a "." from a list in Common Lisp?
I'm new on lisp and I'm finding a difficulty while working with "append". I have to reorder a list and put the first element of the input list as the last of the output list. I've trying ...
-1
votes
1
answer
32
views
Efficient append / event logging in simulation model in R
Context:
I'm building a simulation model in R which runs for ~5200 timesteps with ~1000+ individuals. Each timestep, individuals can experience some events with random chance and dynamic rates (~9 ...
-3
votes
2
answers
73
views
How to skip first element of each row in csv file without changing csv file
I am using a for loop in python to convert the values from the csv file into integer and float then putting them in a list in the code itself but the problem is with that the csv file doesn't only ...
1
vote
3
answers
58
views
Appending to a list by adding to the previous value in Python
I have some repeat scenarios where I have an initial list, then I want to add some additional values to the end of the list by taking the last value and adding a constant to it.
I want to repeat this ...
0
votes
1
answer
118
views
Does python 3.12 allows to append items from the list to tuple, I am trying this but getting error TYPEERROR: 'tuple' object is not callable
Please find the below code, once I execute this code I am getting 'tuple' object is not callable error please give the solution, thanks in advance.
`mytuple = ("apple", "banana", &...
0
votes
1
answer
51
views
R adding list to a list and different data type to that list in a list
I want to make a list that represents rows to print; a row contains text and numeric data; I make a toplist that contains for each row a list to print.
The list for rows are constructed from stat.desc ...
-1
votes
2
answers
54
views
Can I write a changing integer value to a list in a loop without overwriting the previous value? [closed]
I have a for loop with an if statement checking if the current character in 'phrase' is equal to a character in 'dictator[column]' and if it is, it will append the position of a character to a global ...
0
votes
2
answers
60
views
Why is my .remove command not working when my .append command is working fine
I'm working on the classroom project where you make a little text based game as an introduction to Python. My dictionary, and most of the if/else for moving between rooms is working fine. Where I'm ...
0
votes
0
answers
13
views
List append dictionary - handling missing data
For reading a HTML-tree, I have a script that reads the element-tree. However, the problem I have is that with creating a list, the script uses for a missing value, the last known value.
However, ...
0
votes
1
answer
47
views
Appending vector creating two separate lists in R
I am new in R and I am quite confused about the data structure. I am dealing with two vectors, each vector containing strings of character as below:
vector1:
vector2:
And in order to append these ...
0
votes
1
answer
51
views
Appending nested dictionary objects to a list based on the values of the nested dictionary object. PYTHON
I've come across an issue with some code I'm writing to display a list of objects that the user can select from. Each object has a given 'Size' attached to it, and each time an object is selected, ...
-1
votes
3
answers
150
views
Arrays Merging Instead of Appending in Python
I'm attempting to append these two arrays as they're built but am getting unexpected results in Python:
This = []
That = []
This.append('A')
That.append(This)
This.append('B')
That.append(This)
...
0
votes
0
answers
39
views
Append a None to List in Robot Framework
my current keyword is checking for the existence of an element and if it exists, appending content found to list:
${present}= Run Keyword And Return Status Page Should Contain Element ${...
0
votes
0
answers
33
views
How can I add together list items that I got from a dictionary?
So this is a simple program I am doing for a homework assignment that I am getting stuck on somewhere in the middle.
Create a program in Python to display a menu on the kiosk at the coffee shop and ...
0
votes
1
answer
43
views
Enter items/elements to a blank list by taking user input
I have written a code and it's working fine, just one problem that iam working with append() and i know that append adds element in the end of the list.
I want the list not to start from a blank ...
-1
votes
1
answer
52
views
In python, i dont know why but in my code im appending to a list but when i check the list theres nothing inside
I'm learning python and im still a beginner and heres my problem:
toppinglist = []
instock = ['Cheese', 'Tomato', 'Chicken', 'Mushroom']
Outofstock = ['Beef', 'Pork', 'Onions']
wanttoppings_q = input('...
-1
votes
2
answers
124
views
How to append li element, to another list
I have a list that i want to append another list on certain conditions.
The structure looks like this:
<ul class="menu">
<li class="list-1"><ul class="ul-1"...
0
votes
1
answer
47
views
When to use append() and when the += operator in Python?
This is my first question on Stack Overflow.
I want to add a new dictionary at the end of an existing list with multiple dictionaries (see example below):
travel_log = [
{
"country": &...
1
vote
0
answers
61
views
Add value in dictionary with inner dictionary [duplicate]
Could you please help with the following problem.
I have a dictionary with the following structure:
{'logtype16777217': {'Table_AmfSetID.csv': [],
'Table_QCI.csv': [],
'Table_body.csv': [],
'...
0
votes
0
answers
44
views
python list.append with for loop
I was wondering if it is possible to add a for loop in a append function.
used code now:
for Master_ii in ExcelSheet_IO.iter_rows(min_row=3):
if Master_ii[0].value != '': #Collect column A to S from ...
2
votes
2
answers
43
views
How to append vector to list of vectors in R without resorting to indices? [duplicate]
Consider for example the list
lExample <- list(c(0, 1, 0), c(1, 3), c(4, 1, 6))
and two new vectors that we would like to append to the former list
v1 = c(5, 3)
v2 = rep(4, 5)
.
One way of doing ...
0
votes
1
answer
135
views
How to add a custom list of stock tickers to an existing list of S&P 500 tickers scraped from wikipedia
I'm a beginner with Python, but with the help of online tutorials and forums like this I was able to write the below code that pulls in the last month of pricing data for all names/tickers in the S&...
0
votes
3
answers
118
views
How to only get one vowel in a list?
I am having trouble getting the function to only print the vowel once if the string contains the vowel more than once. Here is the assignment:
Write Python function vowelList that takes one string ...
0
votes
2
answers
155
views
kdb/q How to append a list to a table?
I have a table like this:
nameTable
Name
Included
Ann
1
Bob
0
Cat
1
I have a function that gets the "bits" from the Included? column:
// get the bits
fGetBits:{[nameTable]
nameTable: ...
0
votes
3
answers
110
views
Appending two lists mutually to each other gives unexpected results containing "[...]"
I have 2 lists:
a = [1, 2, 3, 4, 5]
b = [9, 8, 7]
I performed the following two operations and tried printing each list
a.append(b)
b.append(a)
print(a) # Expected Result: [1, 2, 3, 4, 5, [9, 8, 7]]
...
0
votes
0
answers
14
views
Appending list to list in python: leetcode #46 [duplicate]
I'm solving leetcode problems and got stuck with this code outputting something like [[], [], [] ... []]
class Solution:
def permute(self, nums: List[int]) -> List[List[int]]:
...
-2
votes
3
answers
93
views
Is there a way of finding an item in a list that's in a list?
I'm new to python and i'm experimenting with the functions but i got stuck on this one.
Let's say there are multiple groups in a classroom and a list of names for each group.
I take those lists and i ...
-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 ...
-1
votes
2
answers
70
views
Why does my code create a sublist instead of a new element (Python)?
My code starts with a string that contains a sentence and the category that each word belongs to. Then I store this information in a 2-dimensional list:
cadena ="El/DT perro/N come/V carne/N de/P ...
0
votes
1
answer
50
views
Why are values inside list changing (Python) [duplicate]
I created a list called database and appended 'person' to it. When the values in person change from the for loop it keeps changing the values inside the array as well. The last value in 'reader_data' ...
0
votes
2
answers
15
views
How I append the list of Fibonacci series using Generator?
I tried to print appending list, but I get "None" in the output. When I debug the python code it displays list with series.
`def fib():
a,b = 0, 1
while True:
yield a
...
0
votes
0
answers
23
views
Why is my .append() writing to multiple places in a list? [duplicate]
So, I currently have a pretty convoluted list of lists of lists, that I've been able to manage pretty easily; however, I've had to essentially duplicate that list X times as the data thats being ...
4
votes
5
answers
80
views
Appending List Elements in R
I have two large, ordered lists of integers. I would like the integer length at [i]position of hello to be equal to the length at [i] position of bye.
Here is a simplified reproducible example to ...
0
votes
2
answers
50
views
How to create list from different length of lists using for loop in python?
I have two lists, named start and time. start contains 3 datetime elements. time contains 3 lists, each having length of 841, 600, 840. start[0] contains a date of a particular year, I have to add ...
-2
votes
2
answers
76
views
Best way to create multiple list from a dictionary
What is the best way to create multiple list from a dictionary? My dictionary looks like this:
mydict = {'aaa': ['111', '222', '333'], 'bbb': ['444', '555']}
I'm trying to make lists like this:
aaa ['...
1
vote
0
answers
37
views
Append a value to the front of a list in lisp [duplicate]
Tryin to write a single lisp/scheme expression to insert the new value 'z into the beginning of the list '(a b) to produce '(z a b).
I have tried all sorts of combinations of push, append, define and ...
0
votes
3
answers
55
views
How to add value of input text next to checkbox value in list? And how to add onclick property to the input element
I'm trying to create a to-do list. I created a JavaScript code that appends the HTML tags in the list container. But how can I add the onclick property and text value of the input text next to the ...
0
votes
1
answer
39
views
updating dictionaries in python from list of booleans
I have an empty dictionary I want to add to. My solution works but I want to keep adding for each iteration in a dataset. The outcome is only showing one key:value pair. Is there a way to do this?
My ...
1
vote
2
answers
426
views
Words in a range (lists)
TL;DR: I ended up with mostly the desired result, but it is adding " - in range" or " - not in range" on a new line and I want them to be on the same line. I know I can append the ...
0
votes
1
answer
360
views
why do the Sort Method Return My Output to None? [duplicate]
mylist = []
mylist.append(5)
mylist.append(27)
mylist.append(3)
mylist.append(12)
print(mylist)
mylist = mylist.sort()
print(mylist)
I am learning the list methods I run it and it is showing the ...
1
vote
0
answers
51
views
Getting different output with append and +
Code to get k step separated set of the given string
s = 'AABCAAADA'
k = 3
samp = []
for i in range(0, len(s), k):
samp.append(subsamp)
Using samp += subsamp gives different output
for i in samp:
j = ...
0
votes
1
answer
67
views
Will the list delete its values after the session is done?
I'm trying to append some answers to a list, and that works. But what happens when the session is over? Will that be deleted from the list?
The issue is, when I run the code again, looks like the list ...
0
votes
1
answer
95
views
for loop in Pandas to append values based on list condition
I am iterating through a dataframe of 2 columns, ["Tumor Volume (mm3)"] and ["Drug Regimen"]. I have a 2 lists made, one called Treatment with 4 specific drugs, and an empty list ...
-1
votes
1
answer
59
views
What is causing the 'string index out of range' error when adding a new column to a pandas dataframe using iteration?
I have a dataframe with 51108 rows called 'df' and I want to add a new column called 'metric' based on the values of other column (called 'type') that appear on the following row. When I try to ...
-1
votes
1
answer
68
views
Input is supposed to be list but is taking a str input and producing an error
I am creating a program which is similar to a todo list, but the append method doesn't seem to match the datatype
match user_action:
case "add":
todo = input("Enter ...
0
votes
1
answer
51
views
Can't get Python append to work - list returning empty
I'm calling/importing classes into a main script. Everything is working fine, except when I attempt to .append() a sys.argv[1] list into the function-list of the main calling class.
I've tried to move ...
-3
votes
1
answer
135
views
I am getting "Execution Timed Out (12000 ms)" in codewars [closed]
Here is the task
Delta Generators
In mathematics, the symbols Δ and d are often used to denote the difference between two values. Similarly, differentiation takes the ratio of changes (ie. dy/dx) for ...
0
votes
5
answers
62
views
first item from user input not being included using append function
I'm trying to create a list of numbers from user input.
I tried to use 'append' to create the list so I am then able to calculate the average, but 'append' is not including the first number entered by ...
0
votes
0
answers
35
views
append is randomly causing errors
I am trying to append the new user inputs and for some reason it will give me a NoneType error when I try to use addAccount more than once but then will randomly work more than once.
def ...