<jupyter_start><jupyter_text>[Lists](https://docs.python.org/3/library/stdtypes.htmllists)<jupyter_code>list_kosong = []
print('list kosong: {}, type: {}'.format(list_kosong, type(list_kosong)))
list_of_integers = [1, 2, 6, 7]
list_of_alphanumerics = [0.2, 5, 'Viking', 'is', 'a Dan', '!']
print('total item: {} and {}'.format(len(list_of_integers), len(list_of_alphanumerics)))<jupyter_output><empty_output><jupyter_text>Mengakses nilai item di dalam list<jupyter_code>item_list = ['Lord', 'Uhtred', 'of', 'Bebbanburg']
print(item_list[0])
print(item_list[2])
print(item_list[3])
koordinat = [[12.0, 13.3], [0.6, 18.0], [88.0, 1.1]]  # two dimensional
print('koordinat: {}'.format(koordinat[0]))
print('item kedua dari koordinat pertama: {}'.format(koordinat[0][1]))<jupyter_output><empty_output><jupyter_text>Mengubah nilai item di dalam list<jupyter_code>item_list = [0, 1, 2, 3, 4, 5]
item_list[0] = 99
print(item_list)

# menghapus item index 0
del item_list[0]
print(item_list)<jupyter_output><empty_output><jupyter_text>Mengevaluasi apakah item ada di dalam list<jupyter_code>languages = ['Java', 'C++', 'Go', 'Python', 'TypeScript']
if 'Go' in languages:
    print('Go is there, yayyy!')
if 6 not in [1, 2, 3, 7]:
    print('Angka 6 tidak ada')<jupyter_output><empty_output><jupyter_text>List bersifat `mutable` atau nilai itemnya bisa berubah<jupyter_code>original = [1, 2, 3]
modified = original
modified[0] = 99
print('original: {}, modified: {}'.format(original, modified))<jupyter_output><empty_output><jupyter_text>You can get around this by creating new `list`:<jupyter_code>original = [1, 2, 3]
modified = list(original)
modified2 = original.copy()
modified[0] = 99
print('original: {}, original: {}, modified: {}'.format(original, modified2, modified))<jupyter_output><empty_output><jupyter_text>`list.append()`<jupyter_code>shopping_list = [1]
shopping_list.append('kurma')
print(shopping_list)<jupyter_output><empty_output><jupyter_text>`list.remove()`<jupyter_code>remove_shopping_list = ['Kentang', 'Jeruk', 'Apple', 'Susu']
remove_shopping_list.remove('Kentang')
print(remove_shopping_list)

if 'Kentang' in remove_shopping_list:
    remove_item_list.remove('Kentang')
else:
    print('Kentang sudah di buang.')<jupyter_output><empty_output><jupyter_text>`list.sort()`<jupyter_code>numbers = [8, 1, 6, 5, 10]
#ascending order
numbers.sort()
print('numbers: {}'.format(numbers))

#descending order
numbers.sort(reverse=True)
print('numbers reversed: {}'.format(numbers))

words = ['ini', 'adalah', 'kumpulan', 'kata', 'tidak berguna']
words.sort()
print('words: {}'.format(words))<jupyter_output><empty_output><jupyter_text>`sorted(list)`While `list.sort()` sorts the list in-place, `sorted(list)` returns a new list and leaves the original untouched:<jupyter_code>help(sorted)
numbers = [8, 1, 6, 5, 10]
sorted_numbers = sorted(numbers)
print('numbers: {}, sorted: {}'.format(numbers, sorted_numbers))<jupyter_output><empty_output><jupyter_text>`list.extend()`<jupyter_code>first_list = ['berbuka', 'ngopi']
second_list = ['makan',1 ,3]
first_list.extend(second_list)
print('first: {}, second: {}'.format(first_list, second_list))<jupyter_output><empty_output><jupyter_text>`list.reverse()`<jupyter_code>item_list = ['apple', 'manggis', 'semangka']
item_list.reverse()
print(item_list)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17770452502247527, 'fraction_numerical': 0.022774947557686546, 'mean_word_length': 9.084592145015106, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '12', 'dir': 'jupyter-structured-clean-dedup', 'id': '556123', 'license': 'MIT', 'n_tokens_mistral': 1386, 'n_tokens_neox': 1301, 'n_words': 232, 'path': 'dasar/lists/lists.ipynb', 'repo_name': 'krahman/belajar-python', 'size': '3337'}