variables

same variable with multiple values

same variable with multiple values Question: This is a very simplified version of my actual code in another file: import keyboard def main(): test() def test(): yes = input("enter a ").lower() if yes == "a": test2() def test2(): i = 0 key = "esc" while True: i += 1 if keyboard.is_pressed(key): print(i) # press the …

Total answers: 1

global variable not recognized; says its local variable

global variable not recognized; says its local variable Question: Its not recognizing the global variable. I experienced this issue before and thought the global variable would prevent the error but no matter what i try it always returns this: local variable ‘P1o’ referenced before assignment #import pwinput import PySimpleGUI as sg P1o = ("") P2o …

Total answers: 1

How can i set a variable full of numbers into a list?

How can i set a variable full of numbers into a list? Question: I have a csv file and managed to get access to it and just get the 6th element of each row into a var (buys). Now, I want to take these numbers in buys into a new list to take afterwards a …

Total answers: 3

How to use the output of a function for a second function

How to use the output of a function for a second function Question: I have a function that creates and prints a Dataframe based on the contents of a file: import pandas as pd def DataFrameConverter(file): T = pd.read_fwf(file, header= None, names=[‘1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′]) T = T.rename(index={0:’A’,1:’B’,2:’C’,3:’D’,4:’E’,5:’F’,6:’G’,7:’H’,8:’I’}) df = pd.DataFrame(T) print(df) and a function that is supposed …

Total answers: 2

How do I increment an variable in python every 10 seconds?

How do I increment an variable in python every 10 seconds? Question: So im trying to create an game where the day increase every 10 seconds and the player loses some of his stats, ive tried everything i could think of but im an beginner coder in python. I tried to understand the time/clock library …

Total answers: 1

Why does python pyttsx3 ignore my 3rd input?

Why does python pyttsx3 ignore my 3rd input? Question: I am trying to get pyttsx3 to say text, a variable, and then more text, but for some reason it ignores the 3rd input and moves on to the next line of text. Here is the code: elif "what is the weather" in query: replaced_temp = …

Total answers: 1

Is the color hue of a variable in VS Code telling me something?

Is the color hue of a variable in VS Code telling me something? Question: I have noticed a little curiosity in VS Code with a Python script I am writing: I have some function that returns a numpy matrix B along with a list of parameters called parameters. In the editor, the blue hue of …

Total answers: 1

How to combine multiple similar functions inside a class into, referencing to attributes inside the class

How to combine multiple similar functions inside a class into, referencing to attributes inside the class Question: In the code below you see multiple functions doing almost the same thing yet for another attribute of this class class IDManager(): def __init__(self): self.inputIDs = [] self.outputIDs = [] self.operatorIDs = [] self.dataManagerIDs = [] self.timeManagerIDs = …

Total answers: 1

Text Label from variable value

Text Label from variable value Question: Good afternoon, I have a problem, I would like to know if someone can help me: The aim is to project its value into the text of a label on the next screen. from __future__ import print_function import os.path from google.auth.transport.requests import Request from google.oauth2.credentials import Credentials from google_auth_oauthlib.flow …

Total answers: 1