Hi, I'm brand new to Python and am completely clueless in this assignment. This is the 3rd assignment, but the first without hints on how to import, etc..

The objective of this assignment was to decode a file we are supposed to use the python hw.py < code.txt command with. This confused me right from the start, I understand that it uses the file as the input, but I dont understand how to do that code sided. We are also supposed to be shifting using letter frequencies, which are in percentages, also have not yet been discussed in class. Any help would be greatly appreciated. I have taken a look at the other vigenere ciphers, but they are way to complicated to my understanding.

Thanks a bunch!

Recommended Answers

All 3 Replies

In order to read the contents of code.txt , you'll need to read the stdin pipe. To access it, use the sys.stdin handle, which you can read from just like an open file handle. You'll need to use the sys module, obviously.

The rest is just coding the cypher.

HTH

In order to read the contents of code.txt , you'll need to read the stdin pipe. To access it, use the sys.stdin handle, which you can read from just like an open file handle. You'll need to use the sys module, obviously.

The rest is just coding the cypher.

HTH

alternatively you can just grab the file location as if it was an argument like so:

import sys
f=open(sys.arg[2],'r')

That should do it as well.

import sys
f=sys.arg[2]

my bad

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.