プログラムを実行して何かを選択すると、入力を認識しないことがあります。申し訳ありませんが明らかな間違いがある場合。私はまだこれでかなり新しいです。すべての助けを前もってありがとう。 これは大きな問題ではありませんが、それは学校のためのものですので、私はそれを修正したいと思います。入力を求めても応答しない
import webbrowser as web
import random as rand
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
while True:
user_input1 = str(input(': '))
print('')
#Website Listings:
if user_input1 == '1':
print('1: Google')
print('2: Youtube')
print('3: 9GAG')
print('4: CanYouRunIt')
user_input2 = str(input(': '))
if user_input2 == '1':
web.open('https://www.google.co.za/')
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
if user_input2 == '2':
web.open('https://www.youtube.com/?gl=ZA')
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
if user_input2 == '3':
web.open('http://9gag.com/')
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
if user_input2 == '4':
web.open('http://www.systemrequirementslab.com/cyri')
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
#Password Generator:
if user_input1 == '2':
total_digits = 0
max_digits = int(input('How many digits? '))
while total_digits != max_digits:
print(rand.randint(0,9))
total_digits+=1
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
#Number Guessing Game:
if user_input1 == '3':
print('')
lower_value = int(input('Lowest Number: '))
print(' ')
higher_value = int(input('Highest Number: '))
print(' ')
tries = int(input('Amount of tries before failure: '))
print(' ')
answer = rand.randint(lower_value, higher_value)
while tries != 0:
guess = int(input('Your guess: '))
if guess > answer:
print('The answer is smaller')
tries-=1
print('You have ' + str(tries) + ' try(ies)' + ' left')
print(' ')
elif guess < answer:
print('The answer is larger')
tries-=1
print('You have ' + str(tries) + ' try3(ies)' + ' left')
print(' ')
elif guess == answer:
print('!!! YOU WON !!!')
print('You had ' + str(tries) + ' try(ies)' + ' left')
print(' ')
break
if tries == 0:
print('!!! YOU LOSE !!!')
print(' ')
break
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
#Calculator:
print('')
if user_input1 == '4':
print('These are your options: ')
print('Type "1" to add two numbers')
print('Type "2" to subtract two numbers')
print('Type "3" to multiply two numbers')
print('Type "4" to divide two numbers')
print('Type "5" to determine the product of an exponent')
print('Type "6" to return to main screen')
print('')
user_input3 = input('What do you want to do? ')
if user_input3 == '6':
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
elif user_input3 == '1':
num1 = float(input('Please enter the first number: '))
num2 = float(input('Please enter a second number to add: '))
result=str(num1 + num2)
print('The answer is: ' + result)
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
elif user_input3 == '2':
num1 = float(input('Please enter the first number: '))
num2 = float(input('Please enter a second number to subtract: '))
result=str(num1 - num2)
print('The answer is: ' + result)
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
elif user_input3 == '3':
num1 = float(input('Please enter the first number: '))
num2 = float(input(' Please enter a second number to multiply: '))
result = str(num1 * num2)
print('The answer is: ' + result)
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
elif user_input3 == '4':
num1 = float(input('Please enter the first number '))
num2 = float(input('Please enter a second number to divide by: '))
result = str(num1/num2)
print('The answer is: ' + result)
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
elif user_input3 == '5':
num1 = float(input('Please enter the base number: '))
num2 = float(input('Please enter the exponent: '))
result = str(num1 ** num2)
print('The answer is: ' + result)
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))
else:
print('Unknown command')
print('')
print('1: Website Listings')
print('2: Password Generator')
print('3: Number Guessing Game')
print('4: Calculator')
user_input1 = str(input(': '))