Reputation: 14 Tradesman
- Active Members
- Active Posts:
- 61 (0.13 per day)
- 21-November 12
- Profile Views:
- Last Active:
- A minute ago
- Viewing Topic: problem with loops
- Dream Kudos:
Posts I've Made
Posted 4 Mar 2014The list comprehension code you posted does not "find words which start and end with a consonant". I would suggest you check it more thoroughly.
Posted 28 Feb 2014It prints "result" is not defined when it hits the last line, which was not one of the options. If you posted the code incorrectly then so be it, but if this is the actual question I would call them on it so they can fix it for future users.
Posted 25 Feb 2014
QuoteWhen I try it on a PNG that I got off the internet it works fine but when I try it with an image that I created using R it does not work
First, check that it is a valid PNG file. The magic number is .PNG but the first character is decimal 137, not a dot. You should be able to view the file, or print the first four characters, and check for dec 137 + "PNG".
Also, you can convert it to any other format and then to PNG using ImageMagick's convert program, which will assure that it is now a valid PNG file.
QuoteWhich says it is in some other format and the image viewer goes with the magic number and opens it, or the image viewer isn't as strict as the PDF requirements.(I can open the PNG in an image viewer and it is not a black box)
Posted 25 Feb 2014You are converting spaces and newlines as well. Split the read, using readlines and then strip and split each line on the space, unless each line is one word, then the split isn't necessary. Write each line individually and append a newline and you should be good to go.
Posted 16 Feb 2014This is a simple example using lists to convert for numbers up to 100 (if I understand Roman Numerals correctly). To make this workable code for larger numbers, you would possibly want to use a dictionary to convert for however many digits you want as a max. Or you can use a list of lists and process the number right to left, so the units would access the zero sub-list to use to convert, tens the  sub-list, etc. Note the code is not thoroughly tested and is meant to be an example for a starting point. Whenever code contains many if/elif/else statements, there is a usually a better way to code it.
units=("", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX") tens=("", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC") for test_it in range(100): ten, unit = divmod(test_it, 10) print test_it, tens[ten]+units[unit]
- Member Title:
- D.I.C Head
- Age Unknown
- Birthday Unknown
woooee hasn't added any friends yet.