Help needed - Printable Version +- Support Forums (https://www.supportforums.net) +-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87) +--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18) +---- Forum: Python Programming Language (https://www.supportforums.net/forumdisplay.php?fid=32) +---- Thread: Help needed (/showthread.php?tid=2574) |
Help needed - Kenji Harima - 11-05-2009 Hey guys I just started to learn about python and I wanted to make a code that replies an answer to a prelisted question so what should it look like? RE: Help needed - Gaijin - 11-05-2009 I guess the reply is on some website. So you should look about the urllib2 module. RE: Help needed - Kenji Harima - 11-05-2009 No I want to make a simple py code that when asked a predefined question will answer back with a predefined phrase. RE: Help needed - Gaijin - 11-05-2009 There are better ways of doing this but I'm a bit n0ob myself, but it does the job! Code: #! usr/bin/env python questionList is a list/array where you store your questions, questionId is used in the loop to get the right answer for the question. print answer[questionId][0] would output "I'm a snake.." if the user types "What are you" I've made this so it can be used with random function to output random answer for a specific question. RE: Help needed - Kenji Harima - 11-05-2009 Thanks dude very appreciated. I'll ask you if I need any more help. |