Skip to content
This repository was archived by the owner on Dec 1, 2022. It is now read-only.

Latest commit

ย 

History

History
33 lines (28 loc) ยท 1.07 KB

string_module.md

File metadata and controls

33 lines (28 loc) ยท 1.07 KB

์•ŒํŒŒ๋ฒณ์„ ๋ชจ๋‘ ์ถœ๋ ฅํ•ด๋ณผ๊นŒ?

์ž…๋ ฅ์œผ๋กœ 0์„ ์ฃผ๋ฉด ์†Œ๋ฌธ์ž ์•ŒํŒŒ๋ฒณ, ์ž…๋ ฅ์œผ๋กœ 1์„ ์ฃผ๋ฉด ๋Œ€๋ฌธ์ž ์•ŒํŒŒ๋ฒณ์„ ์‚ฌ์ „ ์ˆœ์œผ๋กœ ์ถœ๋ ฅํ•˜์„ธ์š”!


input example:
0

output example:
abcd...


input example:
1

output example:
ABCD...


์•„๋งˆ ๋งŽ์€ ๋ถ„๋“ค์€ ์ด๋ ‡๊ฒŒ ์•ŒํŒŒ๋ฒณ์„ ์ถœ๋ ฅํ•˜๊ธฐ ์œ„ํ•ด ๋ชจ๋‘! ์ž…๋ ฅํ•  ๊ฒƒ ๊ฐ™์•„์š”.
answer = 'abcdefghik....'


๋ณด๋‹ค ํŒŒ์ด์ฌ๋‹ต๊ฒŒ ์ž‘์„ฑํ•œ๋‹ค๋ฉด?

ํŒŒ์ด์ฌ์œผ๋กœ๋Š” ์•„์ฃผ ๊ฐ„๋‹จํ•˜์ฃ . string ์ƒ์ˆ˜๋ฅผ ์ด์šฉํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค!

import string
num = int(input().strip())

if num == 0:
  print(string.ascii_lowercase)
elif num == 1:
  print(string.ascii_uppercase)

# ์ถ”๊ฐ€๋กœ ๋Œ€์†Œ๋ฌธ์ž ๋ชจ๋‘, ์ˆซ์ž ์ถœ๋ ฅํ•˜๋Š” string ์ƒ์ˆ˜
string.ascii_letters
string.digits

string ์ƒ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๋‹ˆ ๋„ˆ๋ฌด๋„ ์†์‰ฝ๊ฒŒ ๋‚˜์—ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๋” ๋งŽ์€ string ์ƒ์ˆ˜๋ฅผ ์•Œ๊ณ ์‹ถ๋‹ค๋ฉด ์ด๊ณณ์„ ํด๋ฆญํ•ด์ฃผ์„ธ์š”.