I made a prior discussion where I was unable to properly explain myself. This is my most up to date code that does what I want with 3 items. I would like to turn this into a function using a list so that it can ask how many items you want to use and then run the code that I
Tag: loops
Function with two loops
I want to make a function what must have 2 loops: must check that at least 2 characters (letters) are inserted if the two characters are in the form that the variable must receive at the end, the variable receives the correct orthographic form. Here is my code (but it throws me in infinite loop) [Please be indulgent im a
Python – Reset Increment
I have a list of values in a column (A) and want to increment by 1 in column (B) until the value in A changes, however, having difficulty in my loop to reset the increment when A changes. Here is desired output: Product(A) No.(B) Apple 1 Apple 2 Apple 3 Orange 1 Orange 2 Orange 3 Orange 4 Orange 5
Printing between two number ranges with a given step value
I am new to loops, and I am trying to iterate over all items in a list, and I need to generate the values between 0 and 2 with a given step value. I have tried to use the “range” function, but cannot get it to work. The end result should look something like this (doesn’t have to be in
How to loop over unique dates in a pandas dataframe producing new dataframes in each iteration?
I have a dataframe like below and need to create (1) a new dataframe for each unique date and (2) create a new global variable with the date of the new dataframe as the value. This needs to be in a loop. Using the dataframe below, I need to iterate through 3 new dataframes, one for each date value (202107,
While/For/If Else Loop after checking user input
I’m new to Python and learning. I’m trying to write a program to: User input full name (with space) Check duplication to a list (I used split and join to compare strings) If find a duplication, re-input new name If not, simply break the loop and print “Thanks” I only need to print “Duplicated” or “Thanks” 1 time, not multiple
Python Loops result not understanding [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 6 months ago. Improve this question Can anyone please help explain what the hell is going on with this
multiple for in python query loop and save them
need to save them into different data frames the expected result is running these batches for each class individually. e.g df_class1, df_class2 df_class3, df_class4 each results as sth like ;df_class1, df_class2 df_class3, df_class4 Answer You can use formatted string to save the resultant dataframe for each iteration.
How to accumulate in a df parsed data through a loop with pandas from a web scrapping?
I want to create a df with an historical dataset by scrapping a website, but I struggle to accumulate the full period within the loop. I am able to download a day, but when I try to create a loop to storage a set of iterations I am not able to accumulate the data in the dataframe. The df I
Python re-setting the for loop if an element is deleted in an iteration
The above code is an idea to explain the task what Iam performing. I have a list that Iam looping through when it finds something or meet some condition it will delete that specific index element accordingly. For instance if it finds element ‘c’ in the list then it will delete it from the list but it throws an IndexError: