Saturday, August 13, 2022

[FIXED] Why Python return 'None'

Issue

'''

  function 'text_strip_split(text)' delete special symbolsand
  whitespace in start and end string,after we enter number of word ,
  that it should write , and finally write this word.

'''

def text_strip_split(text):

    list = [ '!' , ',' , '.' , '?' , ':' , '/' , '*' , '#' , '%' , '\\' , '_' , '-' , '=' , '+' , '&' ,';']

    for i in list:
        text = text.replace( i  , ' ').strip()
    text = text.split()

    print()

    while True:
        x = int(input('Enter number word that i should print on console:\n')) - 1
        if x > len(list) or x < 0:
            print('Enter other number!')
        else:
            break

    print(text[x])


word = input('Write the something text with special symbols: \n')
print(text_strip_split(word))

Solution

You have no return statement in the function.



Answered By - RomaValcer
Answer Checked By - Marie Seifert (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.