0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Python 基本コード2

Last updated at Posted at 2018-04-23
team=['sato','nao','john','lisa','kaoru','ryo','bob','jack','mary','linda','yosuke','takashi','saori', 'yuki','tomo', 'take','yusuke','nori','mari','sachi']
boss=['john','lisa','bob','jack','takashi','nori','mari','sachi']
even=[]
odd=[]

cnt = 1
for member in team:
    if(cnt%2 == 0):
        even.append(member)
    else:
        odd.append(member)
    cnt = cnt + 1
print(even)
print(odd)

['nao', 'lisa', 'ryo', 'jack', 'linda', 'takashi', 'yuki', 'take', 'nori', 'sachi']
['sato', 'john', 'kaoru', 'bob', 'mary', 'yosuke', 'saori', 'tomo', 'yusuke', 'mari']


team=['sato','nao','john','lisa','kaoru','ryo','bob','jack','mary','linda','yosuke','takashi','saori', 'yuki','tomo', 'take','yusuke','nori','mari','sachi']
boss=['john','lisa','bob','jack','takashi','nori','mari','sachi']
even=[]
odd=[]

cnt = 1
for member in team:
    if(cnt%2 == 0):
        name = member + ' even'
        even.append(name)
    else:
        name = member + ' odd'
        odd.append(name)
    cnt = cnt + 1
print(even)
print(odd)


['nao even', 'lisa even', 'ryo even', 'jack even', 'linda even', 'takashi even', 'yuki even', 'take even', 'nori even', 'sachi even']
['sato odd', 'john odd', 'kaoru odd', 'bob odd', 'mary odd', 'yosuke odd', 'saori odd', 'tomo odd', 'yusuke odd', 'mari odd']
def show_member(num):
    even=[]
    odd=[]
    
    for n in range(len(boss)):
        if(n%2==0):
            even.append(boss[n])
        
        else:
            odd.append(boss[n])
            
    if(num%2==0):
        print_member(even)
        
    else:
        print_member(odd)
        
        
def print_member(mlist):
    for member in mlist:
        print(member)

#ぶんりする
def show_boss(n):
    boss=['john','lisa','bob','jack','takashi','nori','mari','sachi']
    print(n)
    for n in range(n):
        print(boss[n])

def say():
    print('hello')       

def sayst(word):
    print('---------')
    print(word)
    print('---------')
    
sayst('start')
show_boss(5)
say()
sayst('end')

---------
start
---------
5
john
lisa
bob
jack
takashi
hello
---------
end
---------
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?