Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ahmad Dzikrul Fikri
1806196806-DDP1
Commits
a89c4888
Commit
a89c4888
authored
May 01, 2020
by
Ahmad Dzikrul Fikri
Browse files
Tugas Pemrograman 10 - Soal 2
parent
62c1f8aa
Changes
1
Show whitespace changes
Inline
Side-by-side
TP10_1_1806196806.py
0 → 100644
View file @
a89c4888
from
random
import
randint
def
nomor_atm
(
berkas
=
"nasabah_awal.txt"
):
try
:
data
=
open
(
berkas
)
s
=
{}
for
line
in
data
:
line
=
line
.
replace
(
'
\n
'
,
''
)
line
=
line
.
replace
(
''
,
''
)
nama
,
kota
,
level
=
line
.
split
()
if
kota
.
lower
()
==
'jakarta'
:
kode_kota
=
'01'
elif
kota
.
lower
()
==
'bekasi'
:
kode_kota
=
'02'
else
:
kode_kota
=
'03'
if
level
.
lower
()
==
'emas'
:
kode_level
=
'01'
elif
level
.
lower
()
==
'perak'
:
kode_level
=
'02'
else
:
kode_level
=
'03'
kode_acak
=
str
(
randint
(
10000
,
99999
))
value
=
kode_kota
+
kode_level
+
kode_acak
s
[
nama
]
=
value
data
.
close
()
except
KeyError
:
print
(
'Value hanya boleh terdiri dari satu tipe data (tidak boleh campuran)
\n
'
)
except
SyntaxError
:
print
(
'Key hanya boleh terdiri dari satu tipe data (tidak boleh campuran)
\n
'
)
except
FileNotFoundError
:
print
(
'File tidak ditemukan
\n
Pastikan file berada di foldder yang sama
\n
Pastikan terminal terhubung dengan folder file
\n
'
)
return
s
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment