Как вы вводите список символов от пользователя, используя массивы в Python

Вы можете либо сделать:

x = raw_input("enter your name")
print "your name is %s " % x

, либо:

x = str(input("enter your name"))
print "your name is %s" % x
0
задан barbsan 29 March 2019 в 06:59
поделиться

2 ответа

n=int(input('enter times : '))
name =list(map(str, input("enter name spe by space : ").strip().split()))
if len(name)==n:
    name2 =[i for i in name if len(i)>=5]
    print("name are ->", *name2)

"""
output 

enter times : 3

enter name spe by space : john edward philips
name are -> edward philips

"""
0
ответ дан prashant rana 29 March 2019 в 06:59
поделиться

Продолжая комментарии, сделайте это простым для понимания:

n = int(input("Enter the number of names first"))

nameLst = []           # an empty list to store the desired names
for i in range(0,n):
    y = input("Enter the names one by one")     
    if len(y) > 5:               # if the len of name is > 5
        nameLst.append(y)        # append it to the list

for i in range(len(nameLst)):    # iterate over the len of the list
    print(nameLst[i])            # print all the names in the list
0
ответ дан DirtyBit 29 March 2019 в 06:59
поделиться
Другие вопросы по тегам:

Похожие вопросы: