return

Python function doesn't return list[int] – solved

Python function doesn't return list[int] – solved Question: I’m still a beginner with just a few months experience in programming. I’m writing a program to roll dice in a few modes. I’m having a problem with my Selective mode. Code: from os import system from platform import system as operating_system from random import randint, randrange …

Total answers: 1

why does python print not working after return?

why does python print not working after return? Question: Why does print statement not run after I return in recursion in Python? arr=[‘zero’,’one’,’two’,’three’,’four’,’five’,’six’,’seven’,’eight’,’nine’] def numToWord(num): if num==0: return dig=num%10 num=num//10 #print(arr[dig],end=" ") return numToWord(num) print(arr[dig],end=" ") numToWord(345) Asked By: VVarun || Source Answers: **A return is a value that a function returns to the calling …

Total answers: 2

Passing return value to function

Passing return value to function Question: I’m having difficulty understanding how to use return values. def grab_name(string): return grab("users/self/profile", string) def print_user_info(arg): print(grab("users/self/profile", "janice")) I need to consume the result of passing the first function in order to print the user info. But I’m not sure how to do that…the second function is not supposed …

Total answers: 2

How to use Dict to specify type-hint in Python

How to use Dict to specify type-hint in Python Question: I have a function which will return a dictionary like: from typing import Dict def foo() -> Dict[]: params = { "side": "Buy", "symbol": "BTCUSDT", "order_type": "Market", "time_in_force": "PostOnly", "reduce_only": False, "close_on_trigger": False, } return { "method": "POST", "api": "private/linear/order/create", "body": params } What should …

Total answers: 2

How does a "return" function end the execution of a Python script?

How does a "return" function end the execution of a Python script? Question: I am told that the following python-code does return me a true/false statement wether at least one element of the list "nums" is divisible by 7 (yeah, and for a 0). But let’s say that the first value in the list is …

Total answers: 5

Why is the return function not passing the variables to the next function?

Why is the return function not passing the variables to the next function? Question: I’m trying to get rid of the error without moving the input function out of the userInput function. I expected the return function to remove the NameError. I looked all over stack exchange and in my textbook to figure out this …

Total answers: 2

When to return in function in Python?

When to return in function in Python? Question: I am creating a program that will accept user input and from that, generate a name and a backstory. What I am having trouble with is printing the indefinite articles "a" or "an," depending on the backstory string’s first letter. # Backstory a = "alchemist searching for …

Total answers: 1

Where did the "None"s come from? | Python map() function

Where did the "None"s come from? | Python map() function Question: I wrote a little code that uses the map() function: def function(a): if a % 2 == 0: return a else: pass x = map(function, (1,3,2,5,6)) print(set(x)) It’s supposed to return every even number that is provided, If it’s an odd number, I don’t …

Total answers: 1

Returning the month index/number instead of month name

Returning the month index/number instead of month name Question: self.months = (‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’) self.option_var = tk.StringVar(self) # option menu option_menum = ttk.OptionMenu( self, self.option_var, self.months[0], *self.months, ) birth_month = self.option_var.get() so, I’m programming an age calculator in python + tkinter and I’m wondering if instead …

Total answers: 1