Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I wrote a simple love program in which for every vowel the user scores points that are the outputted at the end. There is an unknown error in the code and I am unable to notice this so if someone could point this out to me I'd be grateful.
awesome=0
name=input("Enter your name, wasteman")
for char in name:
if char in ["a","e","i","o",u"]:
awesome += 1
print("your awesome level is: " + str(awesome))
["a","e","i","o",u"] <- missing opening quote around `u`
It should be:
["a","e","i","o","u"]
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 months ago.
Improve this question
New to python and working on lists. The items in my lists consists of letters and numbers, and I'm wondering how to print the letters in uppercase. This is what I have.
dirtbike = ['yz450', 'kx450', 'rmz450', 'ktm450', 'fc450']
message = f"I would love to own a {dirtbike[0]}! As well as a {dirtbike[1]}!"
print(message)
I would like the print out to be 'YZ450' & 'KX450' but have only managed to print the whole message in upper using message.upper
You can use the method upper inside the brackets.
message = f"I would love to own a {dirtbike[0].upper()}! As well as a {dirtbike[1].upper()}!"
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
text = "Today I went to the {1N}".format(1N="zoo")
Keyword arguments have to be a valid Python identifier, so not starting with a number.
You could pass a dictionary with the ** operator:
"Today I went to the {1N}".format(**{'1N':"zoo"})
but it's probably easier to use a valid identifier instead.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
elif not in records:
print('File was empty'.format(fname))
I get a syntax error on this line, specifically on the "in" part. Im not sure what is wrong so I would appreciate some help
Although this is valid English, it's missing an operand "something"
elif something not in records:
print('File was empty'.format(fname))
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
whenever I write a code say
x = 0
print("your number is {x}"
it actually prints {x} in visual studio code, instead of the value.
This prints {x} because it's a simple string.
What you need is f-string as mentioned in comment.
Another way around is using string format:
print("your number is {}".format(x))
And an old-school:
print("your number is %s" % x)
Read some more for better understanding.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I've just started Python,
and everything I was doing was working well until I encountered syntax errors when there were apparently no problems :
def things():
answer = int(input()
if answer == 1:
print("wowie my friend")
and I get invalid syntax on the ":" after the if, I don't know why.
Thanks for helping me
Beware of the parenthesis ! Each open one must be closed. It's a common mistake, but always make sure to check you didn't forgot or put an extra one if you have an InvalidSyntaxError.