+ 1
Which is the error in this code
message=(""d89%l++5r19o7W *o=l645le9H "") numbers=(0;1;2;3;4;5;6;6;8;9;%) letters=(a;b;c;d;e;f;g;h;i;j;k;l;m;n;ñ;o;p;q;r;s;t;u;v;w;x;y;z) message=(""numbers*letters"") print(""message-numbers"")
7 Answers
0
---
Main Issues in the Code:
1. Incorrect Use of Quotation Marks
The quotation marks in the code are improperly used:
message=(""d89%l++5r19o7W *o=l645le9H "")
Using "" is uncommon and invalid in most programming languages. Proper single (') or double (") quotation marks should be used.
2. Invalid Array Syntax
The arrays are defined as:
numbers=(0;1;2;3;4;5;6;6;8;9;%)
letters=(a;b;c;d;e;f;g;h;i;j;k;l;m;n;ñ;o;p;q;r;s;t;u;v;w;x;y;z)
In most languages (e.g., Python or JavaScript), array elements should be separated by commas (,), not semicolons (;).
3. Invalid Operators
Some operators or syntax in the code are not valid. For example:
numbers*letters is not a valid operation.
print("message-numbers") doesn't make sense conceptually.
4. Invalid Characters in Variables
Characters like % in the numbers array or elsewhere are not allowed unless used as part of a string.
5. Unclear Programming Language
The syntax appears t
+ 6
Unfortunately this doesn't look like real code at all. I assume you are brand new and wanting to learn to program. That's fantastic. But you're not quite ready for this challenge. To accomplish this task, you need to know a few things first.
The strings are not defined correctly.
There needs to be a loop of some kind
There is not any form of evaluation
We want to help you succeed. Please continue with the course for now. After you have learned a few more lessons you will know about conditions and loops. By then you'll be pretty close to making this script work. Show us what you come up with and we'll help you with any challenges you're having.
+ 4
Laura Daniela Perez
learn some more basic concepts.
The syntax is all wrong.
I'm guessing you're learning Python because it looks likd you were trying to create tuples and using print. But your data are all wrongly formatted and the operations you were trying to apply are all invalid.
Unfortunately, you just can't guess stuff and hope it works.
Maybe this is still beyond your current knowledge.
But if you must, this is how I would solve it:
But you have to understand what's happening by learning the basics first. Maybe you would use a longer solution with more fundamental methods, but your method will still be better than mine if you used things you really understand.
message = """d89%l++5r19o7W *o=l645le9H
"""
# characters we don't want
numbers = "0123456789%"
# characters we want. Note that we also have a whitespace at the end.
letters = "abcdefghijklmnñopqrstuvwxyz "
msg = ""
for c in message.lower():
if c in letters and c not in numbers:
msg += c
print(msg[::-1]) #reverse msg
+ 3
Laura Daniela Perez
Just to motivate you to learn more Python, here is an even more advanced solution: It keeps the uppercase/lowercase of the message. Which is the better solution but might not be the one that is expected.
import string
message = """d89%l++5r19o7W *o=l645le9H"""
numbers = string.digits + string.punctuation
letters = string.ascii_letters
table = str.maketrans(letters,letters,numbers)
msg = message.translate(table)[::-1]
print(msg)
As before, don't just copy-paste. Learn how and why they work and they will be there if you need them. Learning is not just passing tests and getting a certificate.
+ 3
Thank you all, I appreciate your answer I'll keep learning
0
Sorry I'm new to this and I would like to solve this, I have to create a program which delete the numbers in this encrypt code so I can have for an answer "hello world"