So i am working on this function that takes a list as a parameter containing positive int, negative int, and the number 0 (zero). I have written the function using a while function with nested if statements to determine the value of each integer. Here is an example: My question is how do i return each print statement in a
Tag: function
Use fields of one dataframe as conditions to fill a field of another dataframe
I have 2 dataframes, the first is a small dataframe (df1) with information to use to fill a field (named Flag) of the second dataframe (df2). I need to write a function that uses each row of df1 as parameters to fill each row of df2 with a certain value (Y or N). df1 = type q25 q75 A 13
Unexpected indentation when return in python
when I try to return but I got an error in 2nd return signup_result & return login_result https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportUndefinedVariable here is utils.py I also try to tab 2 times to avoid indentation error in return signup_result & return login_result but still got the same error Unexpected indentationPylance Answer The cognito_login() function contains only one line of code return login_result because that
Python function repeating itself after if statement satisfied
I am a beginner python user and I am stuck with a time-calculator program I am trying to create as part of an online certification. The program will calculate in an AM/PM format the time it is added from the initial time and the correct weekday. I have been having problems with this part as for reasons unknown to me
Func for temporary text in many tkinter Entry widget?
I want to put a temporary text in more than 1 entry with tkinter, but my func is not working. I have this situation: Its working, but… I wan’t to use the same func for other entrys, like this one: Any ideas on how to make it universal? Answer Here’s a PlaceholderEntry widget that should to what you want You
How do you pass a function as an argument to another function, but the initial function’s arguments change?
How can you write a function f that takes another function g as an argument, but where function g has arguments that change dynamically depending on what happens in function f? A pseudocode example would be: So when i iterates, function f is called with a new argument i every time. How could that be implemented? I found one can
Get variables from function input and text after
So id like to make varibles from my function input So basically, the if statement should check if the varible is True or not. And i want to use the function input + ”-outcome” to check. Here is an example, to make you understand my problem better! I’ve tried to find a solution but don’t find it anywhere Thanks! Answer
want to make python function a tv_turn_on_or_Off() to print on for first time then off if called again
make a function named tv_turn_on_or_Off() ,it will take no parameter. if called for the first time it will print tv is on. if called again it will print tv is off. Then,if called again will print tv is on Answer Just have a simple flag as your instance variable. By each call you should toggle it:
valid and corrupt lines from file
As you can read, the function validate_data should check the imported file for corrupt and valid lines, then append them to the correct list, and print them. It works, except that, as you can probably see, the lines will not print in a single line. I’m sure I have to make two other lists to append the correct data into
Function to determine whether a word is valid according to some rules
The function is_valid_word should return True if word is in the word_list and is entirely composed of letters available in the hand. Otherwise, returns False. It does not mutate hand or word_list. I notice that if I use return True instead of pass in the code, it does not read other letters in word. I understand why. Are there other