Python Forum
Output with none, print(x) in function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Output with none, print(x) in function
#1
Do you have any suggestions how to change this None in an output value?

I have read that it is because of print(x), but... if I delete or change print(x) to return x, for loop will end at 1 number. I don't want to have list [] output just normally print(x) in function.

def oddNumbers(l=1, r=7):
    for x in range(l, r):
        if x % 2 == 0:
            pass
        else:
            print(x)

print(oddNumbers())
 
Output:

1
3
5
None
Reply


Messages In This Thread
Output with none, print(x) in function - by Vidar567 - Nov-24-2020, 01:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 233 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  problem in output of a function akbarza 9 1,095 Sep-29-2023, 11:13 AM
Last Post: snippsat
  Python VS Code: using print command twice but not getting output from terminal kdx264 4 1,034 Jan-16-2023, 07:38 PM
Last Post: Skaperen
  How to print variables in function? samuelbachorik 3 851 Dec-31-2022, 11:12 PM
Last Post: stevendaprano
  How to output one value per request of the CSV and print it in another func? Student44 3 1,278 Nov-11-2022, 10:45 PM
Last Post: snippsat
  How to print the output of a defined function bshoushtarian 4 1,237 Sep-08-2022, 01:44 PM
Last Post: deanhystad
Sad Want to Save Print output in csv file Rasedul 5 10,688 Jan-11-2022, 07:04 PM
Last Post: snippsat
  Why does absence of print command outputs quotes in function? Mark17 2 1,342 Jan-04-2022, 07:08 PM
Last Post: ndc85430
  return vs. print in nested function example Mark17 4 1,674 Jan-04-2022, 06:02 PM
Last Post: jefsummers
Photo print output none 3lnyn0 4 1,756 Nov-01-2021, 08:46 PM
Last Post: 3lnyn0

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020