Python Forum
I get "None" at the end of my printed result.
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I get "None" at the end of my printed result.
#2
You are assigning "check" the outcome of your function str_analysis()
and the default value of return is None.
So "print(check)" prints "None".

Better pythonic way:
Don´t use print() inside a function that is doing something.
Always return the value of the outcome of this "doing".

def str_analysis(your_input):
        if your_input.isdigit():
            if int(your_input) > 99:
                return "Big number"
            elif int(your_input) <= 99:
                return "Small number"
            else:
                pass
        elif your_input.isalpha():
            return "Your message is all Alpha characters"
        else:
            return "Your message is neither all Alpha nor all Digits"
Reply


Messages In This Thread
RE: I get "None" at the end of my printed result. - by ThomasL - Sep-06-2019, 05:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  coma separator is printed on a new line for some reason tester_V 4 648 Feb-02-2024, 06:06 PM
Last Post: tester_V
  How can histogram bins be separated and reduce number of labels printed on x-axis? cadena 1 982 Sep-07-2022, 09:47 AM
Last Post: Larz60+
  Reverse printed words hindubiceps 7 3,148 Apr-21-2020, 05:19 PM
Last Post: deanhystad
  bytes not being printed as expected Skaperen 2 2,484 Aug-27-2019, 05:33 AM
Last Post: Skaperen
  Change linenumber and filename printed in exceptions like #line in C kryptomatrix 2 2,776 Jul-12-2019, 06:01 AM
Last Post: Gribouillis
  Putting an array for each string that is printed to a loop ClaudioSimonetti 1 2,417 Feb-05-2019, 12:52 PM
Last Post: perfringo
  Why A will be printed twice in the picture Shen 3 4,211 Jul-25-2018, 01:16 PM
Last Post: stranac
  0 error but Not printed Piqurs 5 4,162 Jul-14-2018, 04:43 PM
Last Post: buran
  [Variable as a String]>EscaSpecial characters printed CSA75 4 4,442 Mar-28-2017, 11:59 AM
Last Post: snippsat
  Best software for creating printed reports? birdieman 5 4,588 Feb-02-2017, 02:39 AM
Last Post: birdieman

Forum Jump:

User Panel Messages

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