for-loop

How do I fill a dictionary with indices in a for loop?

How do I fill a dictionary with indices in a for loop? Question: I have a transposed Dataframe tr: 7128 8719 14051 14636 JDUTC_0 2451957.36 2452149.36 2457243.98 2452531.89 JDUTC_1 2451957.37 2452149.36 2457243.99 2452531.90 JDUTC_2 2451957.37 2452149.36 2457244.00 2452531.91 JDUTC_3 NaN 2452149.36 NaN NaN JDUTC_4 NaN 2452149.36 NaN NaN JDUTC_5 NaN 2452149.36 NaN NaN JDUTC_6 1.23 …

Total answers: 1

How to set a variable, that isnt iter variable, to increases in each iteration and doesnt always return to its value prior to its entry into for loop?

How to set a variable, that isnt iter variable, to increases in each iteration and doesnt always return to its value prior to its entry into for loop? Question: import re, datetime def add_months(datestr, months): ref_year, ref_month = "", "" ref_year_is_leap_year = False aux_date = str(datetime.datetime.strptime(datestr, "%Y-%m-%d")) print(repr(aux_date)) for i_month in range(int(months)): # I add …

Total answers: 2

How to edit and delete keys and values in python dict

How to edit and delete keys and values in python dict Question: i have a little problem that needs solving, i have to write a program that saves contacts in a dict and be able to 1- add new contacts 2- delete contacts 3- edit contacts 4- list contacts 5- show contacts i wrote a …

Total answers: 1

Pandas for-loop with a list of columns

Pandas for-loop with a list of columns Question: I’m trying to open links in my dataframe using selenium webdriver, the dataframe ‘df1’ looks like this: user repo1 repo2 repo3 0 breed cs149-f22 kattis2canvas grpc-maven-skeleton 1 GrahamDumpleton mod_wsgi wrapt NaN The links I want to open include the content in column ‘user’ and one of 3 …

Total answers: 2

how to store arrays inside tuple in Python?

how to store arrays inside tuple in Python? Question: I have a simple question in python. How can I store arrays inside a tuple in Python. For example: I want the output of my code to be like this: bnds = ((0, 1), (0, 1), (0, 1), (0, 1)) So I want (0, 1) to …

Total answers: 4

How do I parse using for-loop?

How do I parse using for-loop? Question: My aim is parse "funpay.com"’s offer page. It has to be easy, cause all offer names are inside the same class ‘tc-item’. However I can’t use bs4+requests, because this page loads only if you’re logged in, which I’m doing via cookies (selenium+pickle). Idk how to make it at …

Total answers: 1

.txt file opened in python won't itterate properly

.txt file opened in python won't iterate properly Question: The following contains abridged version of the code for a text card game I am trying to run. It should get a random string for a card from a random line in "cards.txt", and add it to a user’s collection at "user.txt" (user would be the …

Total answers: 1

turn function add(1, 4) into (add, 1, 4)

turn function add(1, 4) into (add, 1, 4) Question: I have been experimenting with using functions to make a mini programming language, but can’t find out how to turn the function add(1, 4) into (add, 1, 4) So far I have this: mem = {} def inp(text): return(input(text)) def store(name, value): mem[str(name)] = value def …

Total answers: 1