Ask the user for its name using raw_input [closed] - python-3.x

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 8 years ago.
Improve this question
How do I write a program that uses raw_input to prompt a user for their name and then welcomes him.
For example that asks: Enter your name, and then the program continues welcoming the user with Hello NAME_OF_THE_USER

This is one of the easiest problem ever. This is my solution (since you tagged your post for Python 3):
name = input('Enter your name: ')
print("Welcome", name)
For Python 2, just change input to raw_input, and remove the parenthesis of the print function.

Related

Substitution without creating a new variable in python [closed]

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 8 days ago.
Improve this question
a = 5
b = 3
How to substitution without creating a new variable in python and JS Or other programming language.
The value of (a) should be replaced by (b), and the value of (b) by (a).
Tried but couldn't without creating a new variable.
you can use :
a , b = b , a
hope it was usefull theres other methos but this is the easiest

Firebase Admin SDK - How to Get User's Last Name [closed]

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 4 months ago.
Improve this question
Is there a way to get user's last name so we can use it inside our welcome message? I tried this code, but it just gave me a complete name; not the last name. How do I get the user's last name? I have sought inside stackoverflow.com, but found nothing at all. Please help me solve this problem. Thank you.
const name = context.auth.token.name;

How to check if file has been closed? python3 [closed]

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 2 years ago.
Improve this question
Im looking for a way to check if file is now closed (you know for sure that he was opened before).
Also Im need that the checking process will keep hapening until the file is actually closed by the user.
Use a context manager:
with open("/some/file.txt") as fin:
text = fin.read()
# Do stuff, possibly involving user input
print("File is now closed.")
The with arranges for fin.close() to be called upon exiting
that code block.

How to change specific part of a string? [closed]

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 3 years ago.
Improve this question
For example, I have a string like this
a = "starlight sunlight"
And I want to change it into
a = "starspot sunspot"
well i guessed you writing this in python so you can use the replace method
enter example
in your case you went to replace the word light with the word spot so just write
a=a.replace("light","post")

Python similar type of string to search [closed]

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 8 years ago.
Improve this question
I have just started learning python and I have a question. I have a text file which I opened. The file has random questions. Now my question is how can I search for any question similar to this type of question "what is your .... " and "how do you ...." and return the whole question . I am using python 3.x. Please help
I highly suggest you spend some time reading about regex. The trick would be to search for a string that includes the first words you want (the "What is your" statement) and ends with a question mark. The following docs should give you quite a bit of clarity.
https://docs.python.org/3.4/library/re.html
https://docs.python.org/3.4/howto/regex.html#regex-howto

Resources