PythonExercises | Solutions for 46 Simple Python Exercises | Learning library
kandi X-RAY | PythonExercises Summary
kandi X-RAY | PythonExercises Summary
Solutions for "46 Simple Python Exercises"
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Decode a RSA key .
- Translate a string .
- Makes theing part of the word .
- Compute word frequencies and print them .
- Return a list of all the words in a semordnemonic .
- Makes a 3 s suffix .
- Print word frequency table .
- Returns the maximum of a and b .
- Checks if li1 and li2 are overlapping
- Returns the maximum value of a list .
PythonExercises Key Features
PythonExercises Examples and Code Snippets
Community Discussions
Trending Discussions on PythonExercises
QUESTION
I'm new to Python and I'm trying to do the following exercise:
With the for loop, take the following list and sort it based on the sum of the values of the tuples of the list: [(1,5),(9,0),(12,3),(5,4),(13,6),(1,1)]
However, when I write the following code:
...ANSWER
Answered 2020-Jul-07 at 15:47The main issue here lies in the line for i in tuple1
.
Your tuple1
is [1,9,12,5,13,1]
. When i=9
, you list is clearly out of range(its length is only 6). Use for i in range(len(tuple1))
instead.
The full code will be
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PythonExercises
You can use PythonExercises like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page