python3で関数型プログラミングをしています。
たった2つだけ関数を作った状態ですが、ここで疑問が湧きました。
一つの関数の処理が終わったらもう一つの関数を実行する、ことを実現するにはどうすればよいのでしょうか?
その方法が分かればきっと応用もできると思うので、益々知りたくなりました。
以下のコードで言うと、input_user_name関数が終了したらinput_password関数を実行したいです。
python3
1def input_user_name(): 2 while True: 3 user_name = input("名前を入力してください: ") 4 if user_name: 5 print("あなたの名前は\"{}\"であってますか?".format(user_name)) 6 user_name_ok = input("はいorいいえ: ") 7 if user_name_ok == "はい": 8 print("保存します") 9 break 10 elif user_name_ok == "いいえ": 11 print("正しい名前を入力してください") 12 print("") 13 continue 14 else: 15 print("はいorいいえを入力してください") 16 continue 17 else: 18 print("") 19 continue 20 21def input_password(): 22 while True: 23 print("passwordは六字以上の整数でなければいけません") 24 print("") 25 password = input("your password: ") 26 password = str(password) 27 if password and len(password) >= 6: 28 try: 29 password = int(password) 30 except ValueError: 31 print("") 32 print("整数を入力してください") 33 continue 34 print("もう一度確認のために入力してください") 35 print("") 36 password_a = input("your password: ") 37 try: 38 password_a = int(password_a) 39 except ValueError: 40 print("") 41 print("整数を入力してください") 42 continue 43 if password == password_a: 44 print("保存します") 45 break 46 elif password != password_a: 47 print("1回目に入力したpasswordと2回目に入力したpasswrdが違います") 48 print("1回目から入力しなおしてください") 49 continue 50 else: 51 pass 52 elif password and len(password) < 6: 53 print("六字以上の整数を入力してください") 54 continue 55 else: 56 print("passwordを入力してください") 57 pass
試したこと
「python 関数が終わったら処理する」でインターネット検索をしてみましたが、期待する内容の記事はありませんでした。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/28 21:10