Я пытаюсь создать программу, которая принимает входные данные и преобразует любые входные данные, например Yes/YES, в нижний регистр, который будет принят в цикле while ниже. Ive пытался это сделать, но не работает. Есть идеи?Преобразование ввода в нижний регистр для принятия в цикле while
#Import the random function - This only needs to be imported once.
import random
#Use a while loop to allow the user to repeat the process
repeat = "YES"
while repeat == "yes":
#User is able to input which sided dice they want to throw.
dice = input("What side dice do you want to use? 4, 6, or 12?\n")
#4 sided
if dice == "4":
#Outputs what sided dice has been chosen and the score thay they rolled.
print(dice, "sided dice chose.\nYou rolled a", random.randint(1,4))
#6 sided
elif dice == "6":
print(dice, "sided dice chose.\nYou rolled a", (random.randint(1,6)))
#12 sided
elif dice == "12":
print(dice, "sided dice chose.\nYou rolled a", (random.randint(1,12)))
#Incorrect value entered
else:
#Informs the user that the number they have chosen is not a valid option.
print(dice, "is not a valid choice")
#Asks user if they want to use the program again.
print("Do you want to use the program again? Yes or No?")
#Links back to the start of the while loop.
repeat = input()
'вход(). Ниже()' –
Это, как представляется, является проблемой что ваше начальное значение повтора - это верхний регистр;) – GreenAsJade
Что вы попробовали? Ваша попытка нижнего индекса не отображается в вашем опубликованном коде. – user2357112