Question

Below is the code i tried using python

 >>> import string
 >>> def main():
    print "hey"
    print
    key = input ("key?")
    message = raw_input("Enter the message: ")
    codedMessage = ""
    for ch in message:
    codedMessage = codedMessage + chr(ord(ch) + key)
    print "the coded is: ", codedMessage


    >>> main()
    hey
    key?-1
    Enter the message: hey how are you?
    the coded is: gdx gnv `qd xnt>

but when i tried this in sage math..... the input function does not work

Was it helpful?

Solution

Unfortunately, to the best of my knowledge, while input and raw_input work from Sage in console mode, neither work from the Sage notebook (which you don't specify, but I'm assuming is what you were using).

OTHER TIPS

raw_input does work in Sage Math Cloud, though with some strangeness right now (see https://github.com/sagemathinc/smc/issues/358). It looks pretty.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top