Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
"none"
#1
Hello,
A student has written this

print('Welcome to NerdCards, a program to help you revise your notes and information.')
skip = input('Please type SKIP to skip the introduction or type NO to continue. ')
s = skip.lower()
msg = print('''There are lots of different ways to revise.
            Classic: Type up 10 flashcards and a prompt for each.
            Keywords: Type up ten cards and prompts with five keywords for each.
            True or false: Type up 10 flashcards and prompts and see if the cards match the promts.''')
if s == ('no'):
  print(msg)
playmode = input('Please type which mode you would like to revise in. ')
m = playmode.lower()
if m == ('classic'):
  print('done')
And it returns a "None" which we can't account for - see image.

https://twitter.com/mel_yuan/status/993669032791293952
Reply
#2
I don't see a return statement (within a function definition). You need to share more complete code if you want help.

I'd expect to see something like this:

def welcome():
    print('Welcome to NerdCards, a program to help you revise your notes and information.')
    skip = input('Please type SKIP to skip the introduction or type NO to continue. ')
    s = skip.lower()
    msg = print('''There are lots of different ways to revise.
                Classic: Type up 10 flashcards and a prompt for each.
                Keywords: Type up ten cards and prompts with five keywords for each.
                True or false: Type up 10 flashcards and prompts and see if the cards match the promts.''')
    if s == ('no'):
      print(msg)
    playmode = input('Please type which mode you would like to revise in. ')
    m = playmode.lower()
    if m == ('classic'):
      print('done')
    
    # need to make sure a valid mode was entered.
    return m

mode = welcome()
By the way, it is considered bad practice to have variable names that are cryptic, especially single letter names. They convey no meaning.
I am trying to help you, really, even if it doesn't always seem that way
Reply
#3
On line 4, the print function returns None, so the value of msg is None. Then you print that None on line 9. You need to remove the print from right-hand side of line4 and keep just the str.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
Thanks.
Reply


Forum Jump:

User Panel Messages

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