2.7 KiB
2.7 KiB
Hints
General
- Tuples are immutable sequence Types that can contain any data type.
- Tuples are iterable. If you need indexes as well as values, use
enumerate() - Elements within tuples can be accessed via bracket notation, using a zero-based index from the left, or -1 from the right. Other Common Sequence Operations can also be used when working with tuples.
1. Extract coordinates
- Remember: tuples allow access via index, using brackets. Indexes start from the left at zero.
2. Format coordinates
- Check
class tuplefor more details on tuples. - Check
class strfor more details on strings.
3. Match coordinates
- What methods could be used here for for testing membership?.
- Check
class tuplefor more details on tuples. - Could you re-use your
convert_coordinate()function?
4. Combine matched records
- Remember that tuples support all common sequence operations.
- Could you re-use your
compare_records()function here?
5. "Clean up" & make a report of all records
- Remember: tuples are immutable, but the contents can be accessed via index using bracket notation.
- Tuples don't have to use parentheses unless there is ambiguity.
- Python has multiple methods of string formatting.
str.format()andf-stringsare two very common ones. - There are multiple textual formatting options available via Pythons
format specification mini-language.