# \#custom-function

**URL:** https://discuss.python.org/tag/custom-function/40.md

[Latest](https://discuss.python.org/latest.md) · [Categories](https://discuss.python.org/categories.md) · [Tags](https://discuss.python.org/tags.md)

---

## [How to see if you're in debug mode](https://discuss.python.org/t/how-to-see-if-youre-in-debug-mode/50260)

<div class="topic-metadata">

**Author:** [@c-rob](https://discuss.python.org/u/c-rob)\
**Replies:** 3\
**Last updated:** [April 14, 2026, 8:25am UTC](https://discuss.python.org/t/how-to-see-if-youre-in-debug-mode/50260 "2026-04-14T08:25:43Z")

</div>

Sometimes I only want print statements to execute if I’m debugging a program, and I don’t want them to execute for the user. Here’s how to tell if you are in debug mode. import sys has\_trace = hasattr(sys, 'gettrace') a…

---

## [Basic function understanding](https://discuss.python.org/t/basic-function-understanding/90351)

<div class="topic-metadata">

**Author:** [@L.Andre](https://discuss.python.org/u/L.Andre)\
**Replies:** 9\
**Last updated:** [May 8, 2025, 5:37pm UTC](https://discuss.python.org/t/basic-function-understanding/90351 "2025-05-08T17:37:46Z")

</div>

Hello everyone, I’m new here ant with python in general and I would be happy to receive support and guidance from you all. I wrote a very easy function that should return a list of objects found in both the provided li…

---

## [Creating a new function in visual studio](https://discuss.python.org/t/creating-a-new-function-in-visual-studio/59485)

<div class="topic-metadata">

**Author:** [@jefink](https://discuss.python.org/u/jefink)\
**Replies:** 5\
**Last updated:** [July 30, 2024, 1:25pm UTC](https://discuss.python.org/t/creating-a-new-function-in-visual-studio/59485 "2024-07-30T13:25:27Z")

</div>

Hello, i’m trying to create a new function with DEF but the terminal just returns the path of the file but it doesn’t print. Can someone please help? def greet(name): print(f"hello, {name} !")

---

## [Incorrect output using the function](https://discuss.python.org/t/incorrect-output-using-the-function/41678)

<div class="topic-metadata">

**Author:** [@vishalsonekar-BA95espanol](https://discuss.python.org/u/vishalsonekar-BA95espanol)\
**Replies:** 4\
**Last updated:** [December 22, 2023, 4:06pm UTC](https://discuss.python.org/t/incorrect-output-using-the-function/41678 "2023-12-22T16:06:22Z")

</div>

I’m trying to run the simple function in #python. But the result is not what it should be. I’ve tried changing the variables and resizing the integer numbers but no help. The output i’m trying to get is 336 i.e sum of…

---

## [Why does one version of my function return None, while the other works fine?](https://discuss.python.org/t/why-does-one-version-of-my-function-return-none-while-the-other-works-fine/37211)

<div class="topic-metadata">

**Author:** [@Brian-M-J](https://discuss.python.org/u/Brian-M-J)\
**Replies:** 4\
**Last updated:** [October 26, 2023, 3:48pm UTC](https://discuss.python.org/t/why-does-one-version-of-my-function-return-none-while-the-other-works-fine/37211 "2023-10-26T15:48:47Z")

</div>

Inspired by the pipeline operator (|\>) in other languages, I tried to implement a function to imitate it. When I use reduce to implement it, it results in None somewhere along the way, but another one using loops works j…

---

## [Apply same set of code to different subsets](https://discuss.python.org/t/apply-same-set-of-code-to-different-subsets/22679)

<div class="topic-metadata">

**Author:** [@hazz292](https://discuss.python.org/u/hazz292)\
**Replies:** 1\
**Last updated:** [January 11, 2023, 7:18pm UTC](https://discuss.python.org/t/apply-same-set-of-code-to-different-subsets/22679 "2023-01-11T19:18:09Z")

</div>

Hello, I want to perform the same data preprocessing code with pandas to different subsets of dataframe. Is there any way to write the code more efficiently without repeating same code for 6 subsets? Thank you!

---

## [Passing a keyboard input into a function](https://discuss.python.org/t/passing-a-keyboard-input-into-a-function/22053)

<div class="topic-metadata">

**Author:** [@CoderCat](https://discuss.python.org/u/CoderCat)\
**Replies:** 6\
**Last updated:** [December 20, 2022, 11:05pm UTC](https://discuss.python.org/t/passing-a-keyboard-input-into-a-function/22053 "2022-12-20T23:05:05Z")

</div>

num = input() def f(a): add = a + 1 return add def p(b): add2 = b + 3 return add2 print(p(f(num))) So this is my code, what it is supposed to do is take a input into function f(), then add 1, then pass variable…

---

## [Function recalling a variable](https://discuss.python.org/t/function-recalling-a-variable/19435)

<div class="topic-metadata">

**Author:** [@Jaywalker061707](https://discuss.python.org/u/Jaywalker061707)\
**Replies:** 3\
**Last updated:** [September 26, 2022, 1:12am UTC](https://discuss.python.org/t/function-recalling-a-variable/19435 "2022-09-26T01:12:54Z")

</div>

def length() len(x) def main(): x = str(input(“entrer a word:”)) length() I get an error message when it runs the length() function saying x is not defined. How can i get a function to pull a user defined variable

---

## [\[SOLVED\]Function output anomaly](https://discuss.python.org/t/solved-function-output-anomaly/17620)

<div class="topic-metadata">

**Author:** [@rob42](https://discuss.python.org/u/rob42)\
**Replies:** 12\
**Last updated:** [July 24, 2022, 4:31pm UTC](https://discuss.python.org/t/solved-function-output-anomaly/17620 "2022-07-24T16:31:07Z")

</div>

I’ve been experimenting with some code from an old book, re-coding the C examples contained therein, into Python3 code and I’ve come across an operation of a custom function that I don’t understand. Maybe someone could …
