Linked Questions

566 votes
19 answers
282k views

I know that some other languages, such as PHP, support a concept of "variable variable names" - that is, the contents of a string can be used as part of a variable name. I heard that this is ...
user avatar
0 votes
3 answers
2k views

Let's say I want to create multiple turtles but also let the user decide how many there is. Is there a way to make a code like this? : n = input() for i in range(n): 'turtle' + i = Turtle() So ...
Sacha Jubinville's user avatar
0 votes
0 answers
2k views

So I have something like this: for j, key in zip(range(10), SomeNestedDictionary.keys()): dictionary1 = SomeNestedDictionary[key] However here dictionary1 , is always the same name. Instead I ...
Euler_Salter's user avatar
  • 3,601
0 votes
0 answers
303 views

I have a dictionary that contains 6 dataframes stored as values. I'd like to convert these values into actual dataframes with the name of the dataframe being the key corresponding to the values. The ...
natnay's user avatar
  • 490
0 votes
1 answer
205 views

I am looping through elements of lists that vary in length and content. Here is the object (keys) that I use: keys: key dims 1 ['site', 'channel', 'fiscal_week'] 2 [...
NLR's user avatar
  • 1,883
0 votes
0 answers
189 views

I am working on a program that store information in different lists using globals. The numer of lists changes everytime the program runs. I want to use the data stored in those lists but don't know ...
Archaeopteryx Psilocybin's user avatar
0 votes
1 answer
129 views

Let's suppose I have a list of strings: people = ['Mike','Paul','Caroline'] and a class: class Person: def __init__(self, name, is_married = False): self.name = name self....
pablopeplo's user avatar
0 votes
1 answer
85 views

I have a list of counters in my code and if it is possible I'd like to avoid to write an if condition for each of them. I figured out the following solution in python 3, but it doesn't works.... how ...
Ignus's user avatar
  • 139
0 votes
1 answer
107 views

Code snippet: data = [("a", "b", "c", "d"),("e", "f", "g", "h")] for i in data: console = '{}_{}'.join(('consoleip',str(i[2]))) <> = Hostdata(hw_id = i[0],location_id = i[1],consoleip = ...
Murphy's user avatar
  • 566
0 votes
1 answer
59 views

sorry for the confusing title, I am unsure of what I am asking but I should be able to explain it better. I have a list of items list = ['s1',s2','s3'] I am iterating of the list no worries: for l ...
Benno's user avatar
  • 119
2 votes
1 answer
70 views

I would like to get a number from the user lets say 3. Now i want to create objects with the name 'user1 = User() , user2 = User(), user3 = User()' is that possible at all? or is there an ...
Schwapo Trix's user avatar
0 votes
2 answers
65 views

Noob question ahead So I am making a basic text-based RPG just to get me back into the basics of Python after being gone for a few months. I'm trying to make a function that has all of the items in ...
HyperdriveMacGee's user avatar
-1 votes
2 answers
69 views

I started making a project that is showing which bands I like, then ask what artist/band's albums they want to see rated by me. I've got it to show what albums I like but then whenever I try to get ...
BaconOfWar66's user avatar
0 votes
1 answer
63 views

judges = ["judge 1", "judge 2", "judge 3", "judge 4", "judge 5",] couples = [1, 2, 3, 4, 5] x=0 j=0 done = False def judging(j, x, judges, couples,): couplescores1 = [] couplescores2 = [] ...
Owen Martin's user avatar
-3 votes
1 answer
55 views

So user should choose between A, B or C and it should put that value into the random int Error message: ValueError: invalid literal for int() with base 10: 'A' option=input() A=a=100 B=b=150 C=c=...
Drunkerino's user avatar

15 30 50 per page