Create your own


#1

```
fav_activities = ["Computer Science", "Reading", "Programming", "Sports", "Friends"]

print "Here are some of my favorite activities and pastimes:"
for f in fav_activities:
    if f == "Help":
        print "WHAT?!?!?"
else: 
    raw = raw_input("What about you?")

while raw == "" or " ":
    raw = raw_input("I'm sorry I didn't catch that. Would you repeat that:")
else:
    raw = raw_input("That's so cool that you're into %s! Is there any  other hobbies you would like to share with me?" %raw)
while raw == "" or " ":
        raw = raw_input("I'm sorry I didn't catch that. Would you repeat that: ")
if raw == "No" or "no":
    print "Well thanks for sharing, see you later!"
else: 
    print "That's very cool! See you later!"

Can someone take a look at this and tell me what's wrong. When I run it, no matter what I type in, it just goes in a loop of "I'm sorry I didn't catch that. Would you repeat that:" It's probably some simple error that a second pair of eyes will catch:) Thank you!
`


#2

fav_activities = ["Computer Science", "Reading", "Programming", "Sports", "Friends"]

print "Here are some of my favorite activities and pastimes:"
print fav_activities
raw = raw_input("What about you?")

while raw == "" or " ":
    raw = raw_input("I'm sorry I didn't catch that. Would you repeat that:")
else:
    raw = raw_input("That's so cool that you're into %s! Is there any  other hobbies you would like to share with me?" %raw)
while raw == "" or " ":
        raw = raw_input("I'm sorry I didn't catch that. Would you repeat that: ")
if raw == "No" or "no":
    print "Well thanks for sharing, see you later!"
else: 
    print "That's very cool! See you later!"

I changed it a little but it still has the same error


#3

Hi @kenzie-beth,
If the exercise is Create your own then they have asked to do this..

Build your for/else statement in the editor. Execution of the else branch is optional, but your code should print a string of your choice to the editor regardless.

so you have to use for/else.

@kenzie-beth
Tho if you still want to know the sources of bugs ,here it is..

Problem1.
while raw == "" or " ":

You need to put your conditions correctly and test for each case then or them like this..

raw == "" or raw == " "

You have to fix this in one more place.

Problem2.
Your final while/else

You need to indent if statement inside the body of while (As you're trying to implement while/else?)


#4

Thank you! I fixed it and it know works.:grinning:


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.