Python Forum
Line 42 syntax error..Help!!1
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Line 42 syntax error..Help!!1
#2
The final line doesn't have a balanced number of quotation marks. The string after counter needs to be in quotes. This would be a little bit easier to do with f-strings. Consider instead:

print(f"You guessed {counter} number(s) correctly.")
Also you are using a random function that picks with the possibility of duplicates and then doing logic to avoid duplicates. You could instead use the method that picks without duplicates

no_duplicates = random.sample(range(1,60), 5)
You are using range(1,60) for the possible picks. That does not include the number 60. If you want 60 to be possible, you need range(1,61).
patpython likes this post
Reply


Messages In This Thread
Line 42 syntax error..Help!!1 - by patpython - Aug-30-2021, 11:12 PM
RE: Line 42 syntax error..Help!!1 - by bowlofred - Aug-30-2021, 11:22 PM
RE: Line 42 syntax error..Help!!1 - by patpython - Aug-30-2021, 11:35 PM
RE: Line 42 syntax error..Help!!1 - by menator01 - Aug-31-2021, 07:08 PM
RE: Line 42 syntax error..Help!!1 - by deanhystad - Sep-01-2021, 03:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Syntax error for "root = Tk()" dlwaddel 15 1,242 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 411 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 1,661 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,256 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  File "<string>", line 19, in <module> error is related to what? Frankduc 9 12,636 Mar-09-2023, 07:22 AM
Last Post: LocklearSusan
  syntax error question - string mgallotti 5 1,346 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,308 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 921 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  Python-for-Android:p4a: syntax error in main.py while compiling apk jttolleson 2 1,891 Sep-17-2022, 04:09 AM
Last Post: jttolleson
  Pandas - error when running Pycharm, but works on cmd line zxcv101 1 1,383 Jun-18-2022, 01:09 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020