python - how do i write my function so that when entered it will print the delimeter is too long? -
I was having trouble writing my function so that when more than one character is entered, this statement is That the delimiter is too long and does not return any value. But I do not know how to do it. New to the Python and it will be a great help with some information. Thanks to what I did in my advance. Def my_split (_, _): my_sep = input ("separator:") my_str = input ("sentence:") def main (): # print your main program here (" My_sep "): Print (" Enter Delimiter Character ") (" my result ": my_sep): if (my_sep & lt; 1): print (" delimiter is too long "). Print any of the print ("Enter a string to split:") ("Enter the delimiter letters:") Print ("Result:") Main ()
if lane (my_sep)> 1: Print ("delimiter is too long") None return But it is not clear where you want to put it in your code. What are you trying to return none ? I think you want something like this: def (main): # your main program here my_str = input ("Enter a string to split:") my_sep = input ( "Enter the delimiter character:") if lane (my_sep) & gt; 1: print ("Delimiter is too long.") Returns no results = # actual partition code, result result = main () print ("result:", result) < P> Fill the actual partition code here , what happens when I run it twice: Enter the string that is dividing: hello Enter the world delimiter character: The result of this is: ['Hello', 'world'] Enter the tring: hello, enter the world delimiter character: See that the delimiter is too long. The result is: none
Comments
Post a Comment