python (attendance records, millet pen questions reversal)

A: attendance records:

Given a string to represent a student attendance records, this record contains only three characters:
'A': Absent-absence
'L': Late late
'P': Present, the scene
if not more than one student attendance records in a 'a' (absence) and no more than two consecutive 'L' (late), then the students will be rewarded.
You need to determine whether he would be rewarded based on the student's attendance record.
Example 1: Input: "PPALLP" Output: True
Example 2: Input: "PPALLL" Output: False

s = input('输入考勤记录:')
if s.count('A') <= 1 and s.count('LLL') == 0:
    print('True')
else:
     print('False')

Here Insert Picture Description
Here Insert Picture Description

Second millet pen questions reversed:

Description Title: Given a sentence (contains only letters and spaces), the position of the word in the sentence is inverted
word dividing a space, only a space between words, no space before> after.
For example:
(. 1) "Hello Xiao mi The" -> "mi The Xiao Hello"

print(' '.join(input().split()[::-1]))

The first:
Here Insert Picture Description

The second:
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/bmengmeng/article/details/94016396