for in python

#for else
for x in range(2):
    print('x : ', x)
else:
    print( 'Final x = %d' % (x))

#Strings as an iterable
string = "Hello World"
for x in string:
    print('Hello World', x)



#Lists as an iterable
collection_list=[]
collection = ['hi', 5, 'd']
for x in collection:
    #print('collection', x)
    collection_list.append(x)
print('collection_list : ', collection_list)  

list_for_range =[]
#list for range
for x in range(len(collection)):
   #print(collection[x])
   list_for_range.append(collection[x])
print('list_for_range : ', list_for_range)


#Loop over Lists of lists
list_of_lists = [ [1, 2, 3], [4, 5, 6], [7, 8, 9]]
for list in list_of_lists:
    for x in list:
        print('list_of_lists ', x)


Popular posts from this blog

com.gpki.secureweb.GPKISecureWEBException: ErrCode=1507,ErrMsg=[GPKI_CMS_ProcessEnvelopedData] 해당 인증서로는 데이터를 풀 수 없습니다.

PL/SQL Developer Tip 선택한 것만 실행

전자정부 EgovMap Xml Jsp