My recommended book for learning Python: Python Crash Course, 2nd Edition: A Hands-On, Project-Based Introduction to Programming. Amazon Affiliate link to support us here at StudySession: amzn.to/2G9pFVA
fruit = {"orange": "a sweet, orange, citrus fruit" "apple": "good for making cider", "lemon": "a sour, yellow cistrus fruit", "grape": "a small, sweet fruit growing in bunches", "lime": "a sour, green cistrus fruit"} # print(fruit) # print (fruit["lemon"] # fruit ["pear"] = "An odd shaped apple" # print(fruit) # fruit ["pear"] = "great with cider" # print(fruit) print(fruit) while true: dict_key = input ("please enter a fruit: ") if dict_key == "quit": break description = fruit.get(dict_key) print(description) print(fruit) veg = {"cabbage": "every child's favorite", "sprouts": "mmmm, lovely", "spinach": can I have some more fruit please"} print(veg) veg.updae(fruit) print(veg) print(fruit.update(veg)) print(fruit) I've tried writing this code again and again, still it gives me an Syntax error...
I write the simple code like A=int(input("Enter your Age:") if A>=18 print ("You are eligible for voting") else print("You are not eligible for voting") But it shows syntax error What could I do?
i have a question i have a syntax error and python keeps on hightlighting my colon even though im doing an if else statement. do you know what error this is
ted1 = input(“How marks did you get on your test out of 100? “) ted2 = int(ted1) if ted2 < 10: print(“U”) elif 10 < ted2 < 20: print(“1”) elif 30 < ted2 < 40: print(“2”) elif ted2 == 100: print(“10”) else: print(“ERROR”) If you need any further explanations let me know :)
i am getting a syntax error when trying to add a variable to a dictionary. dog = { 'name': 'kirby', 'hungry': True, 'weight': 9.5, 'age': 10, 'photo': ("^0-0^") } all of the above variables appear to be working fine but when i add 'health': 100, it says i have a syntax error. im confused because it is following the same structure as the previous.
Hi, I would like help with this, it shows syntax error everytime. print("Superhero Quiz") print("3,2,1.....START") print("Question 1, What is Superman's real name?") print("Your options are n/") print("Option A,Clark Kent") print("Option B, Kent Clark") print("Option C, Tony stark") print("Option D, Kal-El") AnswerA=int(input(" Please Enter your option's alphabet you have chosen as your answer") if AnswerA==1: Mark=Mark+1 else: Mark=Mark+0
""" Mad Libs is a phrasal template word game which consists of one player prompting others for a list of words to substitute for blanks in a story before reading aloud. Author: Hamzah I """ print ("Mad Libs is starting!") name = input("Enter a name: ") first_adj = input("Enter an adjective: ") second_adj = input("Enter a second adjective: ") third_adj = input("Enter one more adjective: ") first_verb = input("Enter a verb: ") second_verb = input("Enter a second verb: ") third_verb = input("Enter one more verb: ") first_noun = input("Enter a noun: ") second_noun = input("Enter a second noun: ") third_noun = input("Enter a third noun: ") fourth_noun = input("Enter one more noun: ") animal = input("Enter an animal: ") food = input("Enter a food: ") fruit = input("Enter a fruit: ") number = input("Enter an number: ") superhero_name = input("Enter a superhero name: ") country = input("Enter a country: ") dessert = input("Enter a dessert: ") year = input("Enter a year: ") STORY = "This morning I woke up and felt %s because %s was going to finally %s over the big %s %s. On the other side of the %s were many %ss protesting to keep %s in stores. The crowd began to %s to the rhythm of the %s, which made all of the %ss very %s. %s tried to %s into the sewers and found %s rats. Needing help, %s quickly called %s. %s appeared and saved %s by flying to %s and dropping %s into a puddle of %s. %s then fell asleep and woke up in the year %s, in a world where %ss ruled the world." print STORY % (first_adj, name, first_verb, second_adj, first_noun, second_noun, animal, food, second_verb, third_noun, fruit, third_adj, name, third_verb, number, name, superhero, superhero, name, country, name, dessert, name, year, fourth_noun) can y’all find the syntax error in this?
The easier way to do this would be using a f-string (if your python is updated), here is a quick video on what they are and how to use them! Link: czcams.com/video/up5XhGRUqq0/video.html However, if you don't have an updated version of Python or want to print it this way that is perfectly fine too, just use the following code for your print statement :)! It should remove your syntax error! print(STORY % (first_adj, name, first_verb, second_adj, first_noun, second_noun, animal, food, second_verb, third_noun, fruit, third_adj, name, third_verb, number, name, superhero, superhero, name, country, name, dessert, name, year, fourth_noun))
Hello I'm a beginner in python.. I hv a task given by my brother is Creat veriable "var1" "var2" And assign value 20 and 30 Perform multiplication operation between var1 and var2 and store the result in "var3" Print "var3" I'm doing it wrong It is showing me syntax error Please help me on this
@@StudySessionYT I fixed the syntax error but I keep experiencing this one: I'm sorry, but an uncaught exception occurred. While running game code: File "renpy/common/00start.rpy", line 210, in script call call _load_reload_game from _call__load_reload_game_1 File "renpy/common/00keymap.rpy", line 493, in script python hide: File "renpy/common/00keymap.rpy", line 493, in python hide: File "renpy/common/00keymap.rpy", line 503, in _execute_python_hide renpy.load("_reload-2") Exception: Couldn't find a place to stop rolling back. Perhaps the script changed in an incompatible way?
Hi, when i put a simple line of code like : print(''StudySession'') It gives me de message: SyntaxError: invalid syntax. What do i do? obs: I'm using 3.9.1 64-bits
Hmm... that shouldn't give you an error if that is all you're entering. Maybe repeat the steps in my how to install python series and maybe that will fix the problem? I assume maybe there is a problem with the Python interpreter for some reason as that shouldn't be giving you an error!
@@StudySessionYT Thank u, but i already fixed the problem, i was just using two quotes instead of just one print(''My name is John'') I'M DUMB ASS FUCK SORRY ;-;
@@ianalexanderamaralbelivuk5693 No worries I'm positive I did a lot worst when I first started learning haha, programming can be tough at the beginning but it is super rewarding, best of luck with your learning :)
I sometimes get a syntax error for this. I sometimes it works.......sometimes it doesn't: student_grades = [9.1, 8.8, 7.5] mysum = sum(student_grades) length = len(student_grades) mean = mysum / length print(mean)
My recommended book for learning Python: Python Crash Course, 2nd Edition: A Hands-On, Project-Based Introduction to Programming.
Amazon Affiliate link to support us here at StudySession: amzn.to/2G9pFVA
Wait its not possible
Some one actually just explained the question and said goodbye without talking about history of how python got created
Simple and Precise explanation. Thanks a lot!
so my error is literaly nothing idk why
fruit = {"orange": "a sweet, orange, citrus fruit"
"apple": "good for making cider",
"lemon": "a sour, yellow cistrus fruit",
"grape": "a small, sweet fruit growing in bunches",
"lime": "a sour, green cistrus fruit"}
# print(fruit)
# print (fruit["lemon"]
# fruit ["pear"] = "An odd shaped apple"
# print(fruit)
# fruit ["pear"] = "great with cider"
# print(fruit)
print(fruit)
while true:
dict_key = input ("please enter a fruit: ")
if dict_key == "quit":
break
description = fruit.get(dict_key)
print(description)
print(fruit)
veg = {"cabbage": "every child's favorite",
"sprouts": "mmmm, lovely",
"spinach": can I have some more fruit please"}
print(veg)
veg.updae(fruit)
print(veg)
print(fruit.update(veg))
print(fruit)
I've tried writing this code again and again, still it gives me an Syntax error...
How do find the syntax error?
If you're using an IDE (like PyCharm for example), it will explicitly tell you there is a syntax error on line 5 for example!
I write the simple code like
A=int(input("Enter your Age:")
if A>=18
print ("You are eligible for voting")
else
print("You are not eligible for voting")
But it shows syntax error
What could I do?
you did not add the colon after else
else:
print("you are eligible for voting"")
i have a question
i have a syntax error and python keeps on hightlighting my colon even though im doing an if else statement. do you know what error this is
Could you copy the text and paste it here so that I can better help you solve the problem?
ted1 = input(“How marks did you get on your test out of 100? “)
ted2 = int(ted1)
if ted2 < 10:
print(“U”)
elif 10 < ted2 < 20:
print(“1”)
elif 30 < ted2 < 40:
print(“2”)
elif ted2 == 100:
print(“10”)
else:
print(“ERROR”)
If you need any further explanations let me know :)
@@StudySessionYT thank you very much I've been stuck on it for a while😁😊
@@walewale7401 no problem, glad I could help!
i am getting a syntax error when trying to add a variable to a dictionary.
dog = {
'name': 'kirby',
'hungry': True,
'weight': 9.5,
'age': 10,
'photo': ("^0-0^")
}
all of the above variables appear to be working fine but when i add
'health': 100,
it says i have a syntax error. im confused because it is following the same structure as the previous.
Are you adding that to the end of your dictionary? I’m just wondering if you have the extra comma on the end that is not needed?
Hi, I would like help with this, it shows syntax error everytime.
print("Superhero Quiz")
print("3,2,1.....START")
print("Question 1, What is Superman's real name?")
print("Your options are n/")
print("Option A,Clark Kent")
print("Option B, Kent Clark")
print("Option C, Tony stark")
print("Option D, Kal-El")
AnswerA=int(input(" Please Enter your option's alphabet you have chosen as your answer")
if AnswerA==1:
Mark=Mark+1
else:
Mark=Mark+0
BRUV DIDNT EVEN ADDRESS HOW TO FIX ANY
"""
Mad Libs is a phrasal template word game which consists of one player prompting others for a list of words to substitute for blanks in a story before reading aloud.
Author: Hamzah I
"""
print ("Mad Libs is starting!")
name = input("Enter a name: ")
first_adj = input("Enter an adjective: ")
second_adj = input("Enter a second adjective: ")
third_adj = input("Enter one more adjective: ")
first_verb = input("Enter a verb: ")
second_verb = input("Enter a second verb: ")
third_verb = input("Enter one more verb: ")
first_noun = input("Enter a noun: ")
second_noun = input("Enter a second noun: ")
third_noun = input("Enter a third noun: ")
fourth_noun = input("Enter one more noun: ")
animal = input("Enter an animal: ")
food = input("Enter a food: ")
fruit = input("Enter a fruit: ")
number = input("Enter an number: ")
superhero_name = input("Enter a superhero name: ")
country = input("Enter a country: ")
dessert = input("Enter a dessert: ")
year = input("Enter a year: ")
STORY = "This morning I woke up and felt %s because %s was going to finally %s over the big %s %s. On the other side of the %s were many %ss protesting to keep %s in stores. The crowd began to %s to the rhythm of the %s, which made all of the %ss very %s. %s tried to %s into the sewers and found %s rats. Needing help, %s quickly called %s. %s appeared and saved %s by flying to %s and dropping %s into a puddle of %s. %s then fell asleep and woke up in the year %s, in a world where %ss ruled the world."
print STORY % (first_adj, name, first_verb, second_adj, first_noun,
second_noun, animal, food, second_verb, third_noun, fruit,
third_adj, name, third_verb, number, name, superhero, superhero,
name, country, name, dessert, name, year, fourth_noun)
can y’all find the syntax error in this?
The easier way to do this would be using a f-string (if your python is updated), here is a quick video on what they are and how to use them!
Link: czcams.com/video/up5XhGRUqq0/video.html
However, if you don't have an updated version of Python or want to print it this way that is perfectly fine too, just use the following code for your print statement :)! It should remove your syntax error!
print(STORY % (first_adj, name, first_verb, second_adj, first_noun,
second_noun, animal, food, second_verb, third_noun, fruit,
third_adj, name, third_verb, number, name, superhero, superhero,
name, country, name, dessert, name, year, fourth_noun))
Hope my previous comment was able to help you!
StudySession thank you so much it did!!
Hello I'm a beginner in python..
I hv a task given by my brother is
Creat veriable "var1" "var2"
And assign value 20 and 30
Perform multiplication operation between var1 and var2 and store the result in "var3"
Print "var3"
I'm doing it wrong
It is showing me syntax error
Please help me on this
I’m trying to define a font and I can’t fix it. It keeps giving me a syntax error. Can you help?
Could you leave a sample of the code giving you the error here?
@@StudySessionYT I fixed the syntax error but I keep experiencing this one:
I'm sorry, but an uncaught exception occurred.
While running game code:
File "renpy/common/00start.rpy", line 210, in script call
call _load_reload_game from _call__load_reload_game_1
File "renpy/common/00keymap.rpy", line 493, in script
python hide:
File "renpy/common/00keymap.rpy", line 493, in
python hide:
File "renpy/common/00keymap.rpy", line 503, in _execute_python_hide
renpy.load("_reload-2")
Exception: Couldn't find a place to stop rolling back. Perhaps the script changed in an incompatible way?
Hi .know matter what I write in my python. I always brings the syntax error stuff.pls get back to me
Could you write here a small bit of code that is giving you a syntax error?
Yes. Something like
class playercharacter:
def__innit__(self, name, age):
Self.name = name
Self.age = age
def run(self):
Print ('run')
Player1 = playercharacter ('ade' '40')
Player2 = playercharacter('ola' '40')
Print (player1.name)
Print (player2.name)
I’m watching videos on what a variable what a string is and what a syntax error is because I have an exam
Hi, when i put a simple line of code like :
print(''StudySession'')
It gives me de message: SyntaxError: invalid syntax. What do i do? obs: I'm using 3.9.1 64-bits
Hmm... that shouldn't give you an error if that is all you're entering. Maybe repeat the steps in my how to install python series and maybe that will fix the problem? I assume maybe there is a problem with the Python interpreter for some reason as that shouldn't be giving you an error!
@@StudySessionYT Thank u, but i already fixed the problem, i was just using two quotes instead of just one
print(''My name is John'') I'M DUMB ASS FUCK SORRY ;-;
@@ianalexanderamaralbelivuk5693 No worries I'm positive I did a lot worst when I first started learning haha, programming can be tough at the beginning but it is super rewarding, best of luck with your learning :)
@@StudySessionYT
Which version of python you use?
I sometimes get a syntax error for this. I sometimes it works.......sometimes it doesn't:
student_grades = [9.1, 8.8, 7.5]
mysum = sum(student_grades)
length = len(student_grades)
mean = mysum / length
print(mean)