Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions U1-Fundamentals/U1.2-Python/chatbot/chatbot-pt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,9 @@ def say_default():
# Check if user_input matches one of the elements
# in valid_responses.
def is_valid_input(user_input, valid_responses):
for item in valid_responses:
if user_input == item:
# If you find a matching response, the input is
# valid for this kind of response.
return True
# If you didn't find a matching response, after
# going through the entire list, the input
# isn't valid for this kind of response.
return False
if user_input in valid_responses:
return True
return False

# --- Put your main program below! ---
def main():
Expand All @@ -46,4 +40,4 @@ def main():

# DON'T TOUCH! Setup code that runs your main() function.
if __name__ == "__main__":
main()
main()
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# Iterate over the list of survey questions and take in user responses.
for x in range(len(survey)):
response = raw_input(survey[x] +": ")
response = input(survey[x] +": ")
answers[keys[x]] = response

# Print the entire dictionary.
Expand Down
4 changes: 2 additions & 2 deletions U2-Applications/U2.1-Data/SurveyProject/surveyproject_pt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

# Iterate over the list of survey questions and take in user responses.
for x in range(len(survey)):
response = raw_input(survey[x] +": ")
response = input(survey[x] +": ")
answers[keys[x]] = response

list_of_answers.append(answers)

done = raw_input("Are you done collecting information? Type YES or NO. ").upper()
done = input("Are you done collecting information? Type YES or NO. ").upper()

# Print the list of dictionaries.
print(list_of_answers)
Expand Down
4 changes: 2 additions & 2 deletions U2-Applications/U2.1-Data/SurveyProject/surveyproject_pt3.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@

# Iterate over the list of survey questions and take in user responses.
for x in range(len(survey)):
response = raw_input(survey[x] +": ")
response = input(survey[x] +": ")
answers[keys[x]] = response

list_of_answers.append(answers)
done = raw_input("\nAre you done collecting information? Type YES or NO. ")
done = input("\nAre you done collecting information? Type YES or NO. ")

# Open the file containing all past results and append them to our current list.
f = open("allanswers.json", "r")
Expand Down