LoginSignup

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 3 years have passed since last update.

Python練習問題3 回答編

Last updated at Posted at 2019-12-08
a = open('text.txt').read().split()
b = []
for i in a:
    b.append(int(i))

b.sort()

for j in b:
    print(j)
  • ファイルを読み込んだものを変数に収める
  • 空のリストを用意する
  • 読み込んだファイルを1行ずつ読み取って、intに変換すし、bの変数のリストに入れていく。
  • bのリストを昇順にならべかえる
  • bのリストをプリントする
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up