SUPPORT UKRAINE
- Your indifference to the act of cruelty can thrive rogue nations like Russia -
タグ
            enumerate
 を含むブログ一覧
        
    
      
    
      
    
      
        
          1
        
      
    
      
    
      
    
 
  
    
        
            【 Effective Python, 2nd Edition 】アンパックのちょっとした使い方 - 1: 一時変数を使わずにスワップする、2: インデックス番号を用いないでネストしている iterable の要素を取り出す -
                    Published 2020年6月10日16:03 by mootaro23
                
                
                    1: 次のようなリストをアルファベット順に並べ替えるとします( sort() を使っちゃダメですよ)。
friends = ['Hana', 'Yuka', 'Nana', 'Saki']
Python に馴染みが薄い方は、次のように一時変数を利用して入れ替えを行うと思います。
def bubble_sort(a):
    for _ in range(len(…
                
            【Python 雑談・雑学】 ループ処理でインデックス番号が使いたいのなら enumerate() を使えば?
                    Published 2020年5月26日21:45 by mootaro23
                
                
                    次のような処理をしています。
top_friends = ['Nana', 'Saki', 'Yuka']
print(f'My top 1 friend is {top_friends[0]}.')
print(f'My top 2 friend is {top_friends[1]}.')
print(f'My top 3 friend is {top_friends[2]}…
                
            
    
      
    
      
    
      
        
          1
        
      
    
      
    
      
    
 
  
                    