![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Feb 2005
Posts: 86
Rep Power: 0
![]() |
say i had a program like this:
a = raw_input("Type either ball, cat, dog, or eat:")
if a == "ball":
print "abcd"
elif a == "cat":
print "abcd"
elif a == "dog":
print "wxyz"
elif a == "eat":
print "wxyz"basically if you were type ball or cat it would print abcd and if you were to type dog or eat it would print wxyz is it possible to not have to repeat typing: print "abcd" 2 times like: if a = "ball" or "cat": print "abcd" i know its not done like that i just wanna know if it can be done somehow Last edited by arod199113; Feb 13th, 2005 at 11:58 AM. |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Actually, what you've done is pretty much right:
if a == "ball" or a == "cat":
print "abcd" |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Feb 2005
Posts: 86
Rep Power: 0
![]() |
thanks
i just didnt know exactly how to do it |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Enjoy yourself. If you want a book on Python, this one's not only good, but free too:
How to Think Like a Computer Scientist: Learning with Python |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|