Don't know what the syntax is

Flight Ticket - Replit

Hi @vinbitstarter, welcome to the forum!

Where are you having trouble with syntax?

Hi @vinbitstarter , welcome to the forums! You need to add a line at the top of your program:

import random

and change line 11 to

random.randint(1,5)
1 Like

that’s not syntax, I guess OP misunderstood. :slight_smile:

@vinbitstarter i think i’ve found the problem

The syntax error in the code is in the following line:

choice=.randint (1,5)

The dot (.) before randint is causing the syntax error. It should be removed. The correct line should be:

choice = randint(1, 5)

This will assign a random integer between 1 and 5 (inclusive) to the variable choice .

1 Like

@vinbitstarter I see that you’ve fixed it. Great! You can mark the post that has helped you the most as a solution to close the topic.

He hadn’t even imported the random module when he asked the question. If you would skip the random in random.randint, he would have to a) from random import randint or b) from random import *

2 Likes

sorry i missed that out

@vinbitstarter Since you have solved this, please close the topic by marking the reply that helped you most as the solution.

This is bad practice and inefficient.

4 Likes

Is import random better? (just wondering)

Yes, but it wouldn’t work with OP’s code.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.