error with string (beginner)
Hello. I get the following error with the following code. Is there something wrong with my Python installation? code: import types something = input("Enter something and I will tell you the type: ") if type(something) is types.IntType: print "you entered an integer" elif type(something) is types.StringType: print "you entered a string" error: String: Source for exec/eval is unavailable -- http://mail.python.org/mailman/listinfo/python-list
break the loop in one object and then return
I am trying to write the following code to block up evaluation and prompting for entering new information. However, when I break the loop in one object and then return it does not start at the beginning again but rather at the point where it exited. Can someone look at the following code and give me some feedback. yournum = input("I am thinking of a number between 1 and 100.\n Guess which number: ") mynum = (yournum-5) def eval(): if yournum == mynum: print "Wow! You got it!" elif yournum < mynum: print "Nope. Too low" again() elif yournum > mynum: print "Oh, your too high" again() def again(): global yournum yournum = input("guess again: ") eval() eval() -- http://mail.python.org/mailman/listinfo/python-list
Re: break the loop in one object and then return
Peter, Why do you make such claims without any reason to do so? This is my own thing. So, I guess I am a student but just a student of my own accord. So, please don't reply if you don't have anything to contribute. As for the - mynum I guess that could happen but I am just doing this so that they will never match on first try. I guess I should just hardcode it. This is what happens if I step though: mynum = 93***1*** yournum = input("I am thinking of a number between 1 and 100.\n Guess which number: ") ***2*** def strt(): ***3******6*** if yournum == mynum: ***7*** print "Wow! You got it!" elif yournum < mynum: ***8*** print "Nope. Too low" ***9*** again()***10*** ***15*** elif yournum > mynum: print "Oh, your too high" def again(): ***4*** ***11*** global yournum ***12*** yournum = input("guess again: ") ***13*** strt() ***14*** strt() ***5*** ***15*** is the problem. It doesn't start at the top but rather where is leaves the loop. Petr Jakes wrote: > It smells like many student are trying to do their homework last few > days here ... Can we now the name of your school? :) > > AFAIK this group does not solve homeworks here :) > > Just few points: > > at the beginning try to test the input value > you can use "in range" or using "0 < yournum < 101" > > you should test if the input is an integer as well.. > http://tinyurl.com/j468c > > Other suggested here which way to go. > > Good luck :) > > Petr Jakes -- http://mail.python.org/mailman/listinfo/python-list
\t not working
I am just learning Python and I am using the book, "Thinking like a Computer Scientist". There is an exercise that I am not able to get working and it is really easy so I thought I would ask for help here. Q: As an exercise, write a single string that: Procuces this output. A? print "produces",'\n',"\t","this","\n","\t","output." -- http://mail.python.org/mailman/listinfo/python-list
Re: \t not working
Sorry, I just realized that if I run it as a script it just drops a line and doesn't tab but if I run it from the shell it outputs perfectly. Thanks for the help. -- http://mail.python.org/mailman/listinfo/python-list
Re: \t not working
ha ha...good point. I didn't realize that you could run it all together. I guess the "single string" part should have been a tip off. Anyway, more questions to come soon. Thanks everyone! -- http://mail.python.org/mailman/listinfo/python-list
SPE output
Does anyone know if there is a way to configure the SPE output? IDLE and Pythonwin IDE both have nicely formatted output that shows tabs and spaces correctly. SPE seems to just print out the text without any formatting. SPE is amazing with the intellisense but maybe there is a better choice out there. Thanks, Alex -- http://mail.python.org/mailman/listinfo/python-list
"Thinking like CS" problem I can't solve
Hello. On page 124 of "Thinking like a Computer Scientist". There is an exercise to take the following code and with the use of TRY: / EXCEPT: handle the error. Can somone help me out? Here is the code: def inputNumber(n): if n == 17: raise 'BadNumberError: ', '17 is off limits.' else: print n, 'is a nice number' return n inputNumber(17) -- http://mail.python.org/mailman/listinfo/python-list
script vs inneractive
I am a little confused because I write most of my programs in a script editor but not all the code executes unless I run it from the inneractive shell. Am I doing something wrong? A good example is "return 1" in a script returns nothing where as in the inneractive shell it will return 1 or true. -- http://mail.python.org/mailman/listinfo/python-list
xcode able to run script?
Does anyone know if it is possible to test your scripts from within the xcode editor? I am currently using Uilipad on windows and there is a sub window that lets you view your output when you launch the script from within the ide. hopefully this makes sense. thanks, Alex -- http://mail.python.org/mailman/listinfo/python-list