I am getting the randit is not an attribute in module random error code

Viewed 43

Whenever i type is rz = random.randit(1, 2) print(rz) it works but whenever i run this code i get the AttributeError: module 'random' has no attribute 'radint. Am i doing something wrong?

import random

user_wins = 0
computer_wins = 0

options = ["rock", "paper", "scissors"]

while True:
  user_input = input("Type Rock/Paper/Scissors or Q to quit: ").lower()
  if user_input == "q":
   break

  if user_input not in options:
    continue


  random_number = random.radint(1, 2)

  #rock:0, paper:1, scissors: 2
  computer_pick = options[random_number]
  print("Conputer Picked", computer_pick + ".")

  if user_input == "rock" and computer_pick == "scissors":
    print("You Won!")
    user_wins += 1

  elif user_input == "paper" and computer_pick == "rock":
    print("You Won!")
    user_wins += 1

  elif user_input == "scissors" and computer_pick == "paper":
    print("You Won!")
    user_wins += 1

  else:
    print("Awww The Computer Won!")
    computer_wins +=1

                  

print("Hope You Had Fun!")

2 Answers
for letter in "PLEASE LEAVE :)":
    print(letter)
    time.sleep(0.05)

You can use a for loop (note that we need to separate these out into individual elements, as the last entry has two characters):

import time
entries = ["P", "L", "E", "A", "S", "E", " ", "L", "E", "A", "V", "E", ":)"]

for entry in entries:
    print(entry)
    time.sleep(0.5)
Related