Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
“C”, “c”, “coffee” or ANY combination of upper and lower case letters
that correctly spells “coffee”, i.e., “Coffee”, “COFFEE”, “coffEE” are acceptable, if doesn't meet requirement program ends, or else the program continues.
You can use str.lower() to make the input lowercase for a case-insensitive match:
import sys
expected = 'coffee'
if input('What do you want? ').lower() not in (expected[0], expected):
sys.exit()
print('Right. Continuing...')
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed yesterday.
Improve this question
Say the user inputs a wrong question and I want to give them 3 chances before it terminates/loses the game. Can I use "if" in that case? How do I structure it where if they input "yes" or want to try again, they'll be able to answer the question till the strikeout?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
Write a Python program that takes the user's name as input and displays and welcomes them.
Expected behaviour:
Enter your name: Nimal
Welcome Nimal
The Python code for taking the input and displaying the output is already provided.
answer for this code!
name = input("Enter your name: ")
print("Welcome", name)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm currently working on a small side project using the steam api, I want to check if the user inputs an url or not.
Could not find anything to this specific problem so if anyone knows that help!
Use regex
Sample Code Below:
import re
regex = r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\"., <>?«»“”‘’]))"
def is_url(input_string):
return re.match(regex, input_string):
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Which name is given a function that is separated by undescore.
function_name.
And to a function like FunctionName? and what would be the right one for python and ANSI C.??
Function names like func_one are written in snake case, while functions written like FunctionOne are written in Pascal case, which is a subset of Camel case where the first letter is also uppercase.
Thanks to #abelenky for pointing out the initial error.
function_name is called a Snake Case. It is the recommended casing for Python.
See this answer for more enlightenment.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a passage. Is there a way from which I could scramble the words from the passage?
First, create a list with all the words of the passage.
If you have the text in another file, use "readlines" and "for" to iterate over it.
Then, use something like:
import random
List_Of_Words = ["these","are","the","words"]
random.shuffle(List_Of_Words)
Hope this helps !