Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added question about a list #14

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions questions/List-manipulate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# RANDLIST

## Question

Welcome to **RANDLIST**! Here is the problem statement:

You must input a number to determine the length of a list that will contain random numbers from 1-100. The last element of the list should be removed 3 times and you must return the list to be displayed in highest value to lowest value order.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a bit more clear? Something like the remove the last element of the list 3 times and then sort the remaining elements


## Input


```python
input_len = input("What is the list length: )
#EXAMPLE USER INPUT = 8

the_list = [4,23,13,2,1,6,56,82]
```

Therefore, your function should return:

```python
[1,2,4,13,23]
```

Here are some criteria for marking someone's code:

- Correctness: Does the code produce correct results for all test cases?
- Readability: Is the code easy to read and understand?
- Efficiency: Does the code run efficiently?
- Style: Does the code follow good coding style and conventions?

Here is a sample solution in Python:

```python
import random

input_len = input("What is the list length: )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
input_len = input("What is the list length: )
input_len = int(input("What is the list length: "))

Input returns a string and we are expecting an integer so this would be a way to avoid that error.
There was a missing quotation mark near the end of the input message.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this function

the_list = []

for i in range(input_len)
x = rand.randint(1,100)
the_list.append(x)
print("the list is" + the_list)

def manipulate(the_list: list) -> list:
for a in range (3):
if len(the_list) ==0:
break
else:
the_list.pop()

the_list.sort(reverse = True)

return the_list



```