Home > other >  Small white consult! Why do I write the code has been unable to perform?
Small white consult! Why do I write the code has been unable to perform?

Time:10-25

Always prompt NameError!
Topic is: the input string contains a consecutive increasing letters, print the string of letters,
Such as: input: abcdf print: e
Please help to see how to change a duck!

CodePudding user response:

First, teach you a way to get the first and last use range () to generate continuous string, use a collection for relationship operation came out

CodePudding user response:

reference 1st floor JMZL response:
teach you a way to get the first and last, using the range () to generate continuous string, use a collection for relationship operation came out

S="12356"

S2=set (CRH (I) for I in range (
[0] word (s), the word (s) [1] + 1))

Print (s2 ^ set (s))

CodePudding user response:

Take it to
 
Le=input ()
L=list (le)
For I in range (1, len (l)) :
If word [I] (l) - word] [I - 1 (l)==1:
The continue
Elif word [I] (l) - word (l] [I - 1) & lt; 1:
Print (' oh, input error, you need to input continuous increment letter string ')
Break
The else:
For j in range (1, word (l [I]) - word (l] [I - 1)) :
Print (CRH (word (l] [I - 1) + j), end=' ')
  • Related