return

Extracting a streaming return variable in my class

Extracting a streaming return variable in my class Question: I’m using bluepy and I have a base code to read values comming from an arduino now I have the problem that when I try to extrac the variable num or tum from def handleNotification I don’t have any succes in the code: So I want …

Total answers: 1

Python: rest of code not playing out when function returns True

Python: rest of code not playing out when function returns True Question: I am coding a trivia game. When the player gets the question correct, the askQuestion function returns True, and the playGame function (which calls upon the askQuestion function) is supposed to add 1 point to the score. However, the score never increases. I …

Total answers: 2

How to assign particular return variable in function on if/else statement in python

How to assign particular return variable in function on if/else statement in python Question: I have two functions as below: def abc(): i = "False" j = "100" return i,j def xyz(): if abc() == "False": #I want to compare "False" with variable "i" print("Not Done") else: abc() == "101" ##I want to compare "False" …

Total answers: 3

why is the return of the program not good?

why is the return of the program not good? Question: I’m new to python and there’s a video on Youtube that I watched. I do the exact same code as he but mine doesn’t work and I don’ understand why. Here’s the code: MAX_LINES = 3 def deposit(): while True: amount = input("What would you …

Total answers: 1

Return variables on the same line – Python

Return variables on the same line – Python Question: I’ve got a for loop which iterates through three elements in a list: ["123", "456", "789"]. So, with the first iteration, it will perform a calculation on each digit within the first element, then add the digits back up. This repeats for the other two elements. …

Total answers: 2

Printing out function containing print and return

Printing out function containing print and return Question: I recently came across a weird problem. I assumed that the two code snippets below should have the same output, yet they do not. Can someone explain? def my_function(): myvar = "a" print("2", myvar) return myvar print("1") print(my_function()) #will output: #1 #2 a #a print("1", my_function()) #will …

Total answers: 1

Why do I keep coming up with an error at the end of my code?

Why do I keep coming up with an error at the end of my code? Question: So when inputting my third elif variable in my main function, my other functions don’t work. My question, is what’s stopping it. Lines 123, 124, 125, keep receiving the "UnboundLocalError: totalcost referenced before assignement" ` def welcome(): print("Hello and …

Total answers: 2

Function is not getting stopped at return at if conditions

Function is not getting stopped at return at if conditions Question: I’m new to python, this below funtion is not getting stop at if condition where it needs to stop. def check_pi_installation_status(): proc1cmd = "grep " + AppName p1 = subprocess.Popen([‘kubectl’, ‘get’, ‘pi’, ‘-A’], stdout=subprocess.PIPE) p2 = subprocess.Popen(proc1cmd, shell=True, stdin=p1.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE) p1.stdout.close() stdout_list = …

Total answers: 1

Trying to solve a number to mnemonics problem using recursion

Trying to solve a number to mnemonics problem using recursion Question: Given a stringified phone number of non-zero length, write a function that returns all mnemonics for this phone number in any order. ` def phoneNumberMnemonics(phoneNumber, Mnemonics=[”], idx=0): number_lookup={‘0’:[‘0’], ‘1’:[‘1’], ‘2’:[‘a’,’b’,’c’], ‘3’:[‘d’,’e’,’f’], ‘4’:[‘g’,’h’,’i’], ‘5’:[‘j’,’k’,’l’], ‘6’:[‘m’,’n’,’o’], ‘7’:[‘p’,’q’,’r’,’s’], ‘8’:[‘t’,’u’,’v’], ‘9’:[‘w’,’x’,’y’,’z’]} if idx==len(phoneNumber): return Mnemonics else: new_Mnemonics=[] for …

Total answers: 2