text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
print(char+alphabet[new_index])
encrypted_text += char
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print('char:', char, 'encrypted text:', encrypted_text)
now my problem is i cant apply the code or (the order mentioned on this step- i need help) and special thanks.
-here the order ( To fix it, add an else
clause after encrypted_text += char
and indent all the subsequent lines of code except the print()
call.)
yes, the instructions are clear, type else: and after that select all the lines except print command then press tab key to indent the lines
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
print(char+alphabet[new_index])
encrypted_text += char
else
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print('char:', char, 'encrypted text:', encrypted_text)
here its, what the next step? (problem still) or error message still appear.
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
Do the instructions provide an example of the syntax of an else
clause?
The syntax is like this
if this:
code
else:
code
If you want more details you can search for “python if else” and get a lot more details and examples.
okay, got it. (thanks)
First, thanks to the moderator for answering me and showing me a new way to post my code to make it more readable.
Second, I need to give this feedback as I face this problem too often. This is the first platform I can give a 5-star evaluation. The main problem I see is that in the help section, you don’t add a feature for code solutions like Codeacademy does. However, Codeacademy requires a subscription to access the full course and certificate, whereas here, you learn for free, which I appreciate very much.
So, if you could add a feature to provide code solutions after some time, I would appreciate it. I noticed that after repeatedly running the code, a simple note appears behind the rest box with instructions to modify the code. Sometimes these instructions are not clear or hard to follow, especially as I am still new to coding. Before I post my question, I search for similar questions posted but often do not reach a solution either. Showing practical examples, like you did above, on how to write readable code is more effective than words alone. Posting my question in the community may take time to get a solution. For example, I was stuck on this step for several hours across different times of the day. Having written code examples would be more time-saving and effective.
I hope my feedback is helpful and leads to new development decisions to make the platform more effective, reaching the top with no cons, just pros.
that is not going to happen, to learn you need to arrive at the solution yourself
I am also grateful for joined this amazing site.
Thank you so much .
I guess you were on step 43: https://www.freecodecamp.org/learn/scientific-computing-with-python/learn-string-manipulation-by-building-a-cipher/step-43
Which does have a practical example of if/else:
if x != 0:
print(x)
else:
print('x = 0')
And if you ever forget then you can do an Internet search and get a lot more details and examples.
okay, got it (by the way, i got the soltuion).
_appreciate each one help me.