Home python строка не найдена

строка не найдена




I ask for help. There is a task:

https://stepik.org / LESSON / CAESAR-CIPHER-23896 / STEP / 1? Adaptive = True & amp; unit = 6422

Caesar cipher is to replace each symbol of the input string to the symbol, which is located several positions to the left or right in the alphabet.

For all symbols, the shift is the same. Cyclical shift, i.e. If the last symbol of the alphabet is used to apply a single shift, it will be replaced by the first character, and vice versa.

Write the program that encrypts the text Caesar cipher.

Alphabet used – space and small symbols of the Latin alphabet: ‘abcdefghijklmnopqrstuvwxyz’

Input format:
The first line indicates the used encryption shift: an integer. The positive number corresponds to the shift to the right. On the second line indicates a non-empty phrase for encryption. Leading and finishing gaps are not taken into account.

Output format:
The only string in which the phrase is recorded: Result: “…”, where the encrypted sequence is recorded inside the quotes inside the quotes inside.

sample input 1:
I am Caesar
Result: "lcdpcfdhvdu"

So, that’s how I decided it:

a = int (input ())
B = Input ()
c = 'abcdefghijklmnopqrstuvwxyz'
res = []
For i in b:
  Res.APPEND (C [(C.Find (I) + A)% LEN_C])
Print ('result:', '"', ''. Join (RES), '"', sep = '')

Interpreter displays everything right. The test does not pass on the site. Tell me, please, where it was wrong.

Answer 1, Authority 100%

My listing for this problem:

alpha = 'abcdefghijklmnopqrstuvwxyz'
n = int (input ())
S = Input (). Strip ()
res = ''
For c in s:
  Res + = Alpha [(alpha.Index (C) + N)% Len (Alpha)]
Print ('Result: "' + Res + '"')

In your code, add the removal of spaces at the beginning and end of the line.

Answer 2

# modules
From Colorama Import *
From Pyfiglet Import *
init ()
title = figlet_format ('Cesar')
Print (Fore.White)
Print (Title)
Print (Fore.green)
While True:
  alphabet = 'abcdefghijklmnopqrstuvwxyz'
  res = []
  LN = LEN (Alphabet)
  N = '. \ / [] {} () = -., ;: \' "1234567890 ~!` @ # $% ^ & amp; * & lt; & gt;? | = + _- '
  For l in str:
    IF NOT L IN N:
      Res.APPEND (Alphabet [(Alphabet.find (L) + Offset)% LN])
      Res.APPEND (L)
  Print (''. Join (RES))

This code sends the characters Enter the image description here

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions