PythonExercise | 100 examples of Python programming exercises | Build Tool library
kandi X-RAY | PythonExercise Summary
kandi X-RAY | PythonExercise Summary
100 examples of Python programming exercises (source code), examples passed the test in the Python 3.6 environment.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Calculate the number of characters .
- Factor n .
- Logs into the user .
- Check if a string is palindrome .
- Combine two components .
- Print data .
- Return the age of n .
- Reverse a string .
PythonExercise Key Features
PythonExercise Examples and Code Snippets
Community Discussions
Trending Discussions on PythonExercise
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 PythonExercise
You can use PythonExercise 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