code to sort some words

Custom encoding

anaconda2017
6 years ago

0

[b]alphalist = [‘while’,‘does’,‘when’,‘been’,‘who’,‘other’,‘why’,‘with’,‘get’,‘all’,‘that’,‘our’,‘not’,‘were’,
‘let’,‘wants’,‘twas’,
‘least’,‘about’,‘their’,‘rather’,‘had’,‘almost’,‘has’,‘able’,‘say’,‘can’,‘where’,‘the’,‘got’,
‘they’,‘tis’,‘into’,‘she’,‘have’,‘because’,‘will’,‘then’,‘and’,‘your’,‘his’,‘most’,‘some’]
sorted(alphalist)[/b]

this code should do sorting but doesn’t accept my answer
help please

3replies
4voices
376views
pedromachuka
6 years ago

0

You should check what is the output of your code, then have a look at how it should be displayed on the answer textarea.

dimooz
6 years ago

0

what is the language you use here?

Overflo
6 years ago

0

Looks like Python to me, since Python has a sorted() command.
you can use
print(sorted(alphalist))
To check the output of your script

Oh, and
alphalist.sort()
Sorts in place, rather than returning a new array (assuming you’re using Python)

Could the reason your answer is incorrect be that you are typing code into the answer box?
I’m pretty sure the “Coding Levels” tasks are asking for an output, such as the alphabetically sorted words, not your code, since you are allowed to do it in any language.

You must be logged in to reply to this discussion. Login
1 of 4

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss