473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Python bot

13
Hey guys, I've really got into python, but I'm still noobish at it.

I have an idea how my Python bot would work. But I can't find the right python code for it.


print "Hi,i'm a bot"
if input == hi
print "Hi yourself"
else:

print "I don't know what you just said"



I know it's something along the lines of that. But "input" doesn't exist. I need to be able to grab the user's input and match it up against "hi".

Since this will be a simply bot. I'll just make 30 or so "statements" that the person can type in and get a response.

Such as "Why is the sky blue" Bot response: Because blah blah blah scientific explanation.

I know this isn't the right type of code. I have the right idea, but I'm not sure how to do this exactly.
Apr 3 '07 #1
4 4447
ghostdog74
511 Expert 256MB
to get input from user , use raw_input().
Apr 4 '07 #2
ilikepython
844 Expert 512MB
also if you want to match it with a string you have to put it in quotes like this:

Expand|Select|Wrap|Line Numbers
  1. x = raw_input("Enter text you wish to display here")
  2.  
  3. if x == "hi":                      #use an if....elif.....else     block
  4.     print "Hi"
  5. elif x == "bye":
  6.     print "see you"
  7. else:
  8.     print "did not understand what you said"
  9.  
Also, you can use a while loop to keep coming back to the raw_input statement thus replaying the if block or whatever you may want to put. Does that help?
Apr 4 '07 #3
gloomer
13
Oh that helps a lot. But do I always have to use raw_input? I may not want a text box popping up each time.

Is there any way to use just a regular input function?

Thanks
Apr 5 '07 #4
@gloomer
There is no text box (besides the console window) that pops up.
Jul 9 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.