0

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"")

26th Nov 2024, 3:01 AM
Laura Daniela Perez
Laura Daniela Perez - avatar
5 Réponses
+ 1
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.
26th Nov 2024, 3:39 AM
Jerry Hobby
Jerry Hobby - avatar
+ 1
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
26th Nov 2024, 4:27 AM
Bob_Li
Bob_Li - avatar
+ 1
Thank you all, I appreciate your answer I'll keep learning
26th Nov 2024, 5:20 AM
Laura Daniela Perez
Laura Daniela Perez - avatar
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"
26th Nov 2024, 3:03 AM
Laura Daniela Perez
Laura Daniela Perez - avatar
0
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.
26th Nov 2024, 5:17 AM
Bob_Li
Bob_Li - avatar