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 am trying to use the newline character in a conditional statement.
The charater is in a list which was made from getting input using sys.stdin.readline(). Here's an example.
string=sys.stdin.readline()
input=list(string)
if (input[-1])=="/n":
print "ok"
Why doesn't this work? If you print the list you see that /n is the last element in the list.
It's '\n' not '/n'. The escape character is a backslash in most languages.
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 3 years ago.
Improve this question
So here is the thing, I have a variable with the list data
[('https://jira.corp.***.com/browse/DE-3872',), ('https://jira.corp.***.com/browse/DE-3839',)].
I'm basically using split() to get the last ID ( DE-3872.. etc)
If I do this ,
for link in data:
issue = data[0][0].split('/')[4]
print(issue)
This is the output I'm getting
DE-3872
DE-3872
It prints the first value twice, but what I'm trying to get is ,
DE-3872
DE-3839
You are printing the same thing twice, use:
for link in data:
issue = link[0].split('/')[-1]
print(issue)
The [-1] index will return the last part of the result.
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 years ago.
Improve this question
I have problem with this if.
I found I can use in in if-statement.
if "log" in sys.argv[1:]
Syntax Error
If you don't show us the code surrounding the if-statement, we cannot know for sure what the problem is. If I were to make a guess however, I'd say you're missing a colon:
if "log" in sys.argv[1:]:
See the documentation for compound statements (like ifs):
Each clause header begins with a uniquely identifying keyword and ends with a colon
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 9 years ago.
Improve this question
Why isn't this giving an output? It is meant to take a sentence as an input and then output the identification of each word.
You never call the function. You do need to run the function to get the output:
print word_identify(words)