The best VPN 2024

The Best VPS 2024

The Best C# Book

3 lines of python code to realize fake chatbot

Spread the love
python code to realize fake chatbot
python code to realize fake chatbot

3 lines of python code to realize fake chatbot, Enter the following code in the Python Console.

Python code to realize fake chatbot

while(True):
    question=input("real person:");
    print("fake robot:"+question.strip("???")+"!");
1
2
3

Learning time is up: Python strip() method The

Python strip() method is used to remove the specified characters at the beginning and end of a string (the default is a space or newline) or character sequence.

Note: This method can only delete the characters at the beginning or end, not the characters in the middle part.

Syntax of strip() method: str.strip([chars]);

Parameters: chars, remove the specified character sequence at the beginning and end of the string.

Return value: Return a new string generated by removing the specified characters at the beginning and end of the string.
E.g:

str = “123abcrunoob321”
print (str.strip( ’12’ )) # The character sequence is 12
1
2 The
output of the above example is as follows:

3abcrunoob3
1

Leave a Comment