Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why do i get a syntax error when importing random?

+5 votes
asked Apr 27 by Matthew Anderson (170 points)
This is my code:

https://onlinegdb.com/VgxGtx4Xq

i get syntax error with the import random, please heelp

3 Answers

0 votes
answered Apr 28 by Peter Minarik (53,530 points)
  1. You are missing a closing parenthesis from the end of your first line
  2. Line 5 should have the same indentation (i.e., none) as the other lines around it.
  3. Your line 5 logic doesn't make sense to me in regards for the rules of the rock-paper-scissor game. More importantly, your trying to set the value of win to win + a random value, but at this point, win (on the right side) is not defined so your code makes no sense to the compiler. Please, review your logic.
0 votes
answered Apr 29 by userdotexe (1,190 points)

I fixed your code: https://onlinegdb.com/wLkBVepCm

:)

0 votes
answered Apr 29 by mohd ashiq (140 points)
length =input("Please enter rock, paper, or scissors.  ")

import random
things = ["rock","paper", "scissors"]
win = random.choice(things)
print(win)
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...