Is it good UX to prompt users before closing the browser window on mobile

i’m designing a mobile web based e-commerce solution. If the user closes the browser window, items in their cart will be lost (assuming they rejected the initial cookie request) when they return. To prevent this i’m considering prompting the user if they are sure they want to close the browser and would like to create an account . Is this a good way to overcome this issue or is there another way?

python – How do I make a loop along with try and except to prompt user until the valid file name is given?

So the desired file name is data.txt. I need to use a loop that continues to prompt the user for file names until the valid file name (data.txt) is entered. My try-except has to be inside the loop.

I must test my program with the loop and a try-except to handle an incorrect name of a file name and continue to prompt the user until a valid file is entered.

For ex, if i enter ‘data’, the program should output:

Enter name of file:
File data not found.
Enter new file name:
File to be processed is: data.txt
Average weight = 164.88
Average height = 69.38

This is my code so far:

if __name__ == '__main__':

    # Complete main section of code
    # Prompt the user for the name of a file
    user_input = input('Enter name of file:n')
    # You should complete the following loop; it will contain the try-except code
    found = False
    while not found:
        # Put your try-except code here
            my_file = open(user_input)
            lines =

            print('File {} not found'.format(user_input))
            file_name = input('Enter new file name:')

    # Print the name of the valid file
    print("File to be processed is: ",file_name)

    # Complete the remaining main section of code to loop through the file, compute the average weight and height, etc.
    average_height = 0
    average_weight = 0

    with open('data.txt') as f:
        for line in f:

            sl = line.split(',')

            average_height += int(str(sl(0)))
            average_weight += int(str(sl(1)))

    print("Average weight = {:.2f}".format(average_height / 8))
    print("Average height = {:.2f}".format(average_weight / 8))

We are asked to make use of the

found = False
while not found: 

as well as putting our try-except code in there.

my code so far only outputs:

Enter name of file:
File data not found.
Enter new file name:

And the calculations below print(“File to be processed is: “,file_name) should be correct.

So I must ask, how do I make use of a loop with try-except in order to prompt the user until a valid file (data.txt) is entered?

Shell – Why doesn't a custom command prompt work as expected on Linux (Debian server)?

I set up a server (Debian) in Virtualbox, customize the command prompt, but I have a problem. When I type in the Command Prompt, it is faulty.

Enter the image description here

This happens when I type in the command prompt, overwrite the command prompt or when I type or the key (up arrow / down arrow). Why?

My configuration is as follows:

PS1='33(1;37mH($(hostname -I | grep -E -o "192.168.(0-9){1,3}.(0-9){1,3}")) (33(1;31mu33(1;37m) <@> 33(1;34mw33(1;37m >> '

Enter the image description here

Enter the image description here

Why does that happen? How can i solve it

Data Entry – How can a user best see a required set of entries associated with an optional prompt?

I feel like this is being duplicated (sorry) but I couldn't find a specific topic for it.

The scenario we are facing is to make it clear to a user that answering a question is optional. However, if he chooses an answer, a certain set of inputs is required as part of that answer. A simple example of this may be that a user is asked for his address, which he skips completely. However, if he chooses an answer, he must provide at least the city, state, and zip code.

So far, our standard has been to indicate each prompt with "(required)" if you need to answer the questions. If our question were required, it would look something like this.

What is your home address? (required)
(___________) Address 1
(___________) address 2
(___________) City*
(___________) Status*
(___________) Post Code*

The only difference for our option question, to which you do not have to answer at all, is the following. The concern is that the city, stage, and zip code entries are still marked as required.

What is your home address?
(___________) Address 1
(___________) address 2
(___________) City*
(___________) Status*
(___________) Post Code*

The currently proposed solution is to mark the fields with a "*" as needed as soon as the user answers one of the 5 entries, so that they are all displayed as optional until data entry is started. This seems logical and then feels overworked and I hope to find out what others may have done.


Terminal – ZSH prompt problem: commands are moved 20 spaces to the right when completed, i.e. H. with the TAB key

In this post it seems to be possible to perform a function inside zsh prompt.

Here's how to use a feature in PROMPT ::

slash_color () { dirs | awk -F "/" ' {for (i=1; i<=NF; i++) printf "33(38;5;75m"$i"33(38;5;206m/"} '; }

PS1='%F{13}|%F{green}%n@%F{cyan}%m%F{13}|%f%T%F{13}|$(slash_color)%F{13}|%F{7} '

Under the result:

Enter the image description here

PROBLEM: But now I'm facing another problem: if I'm in a directory, for example the first completion with TAB vim + TAB Move the entire display from vim + TAB about twenty spaces to the right.

Here is a screenshot for illustration:

Enter the image description here

As you can see, right after typing vim te and press TAB Key, the command vim te is shifted to the right (about twenty characters): I don't understand where this shift could come from.

I saw this last post on a similar problem: Zsh moves text if the command prompt is too long

I use zsh-5.8 from MacPorts.

If someone could have an explanation / suggestion / hint, it would be okay to say so.

PS: I suspect using a simple ZSH environment variable could fix this strange behavior.

Terminal – iTerm2 and zsh-5.8: Dynamically replace each slash in PROMPT with a different color in order to better recognize the arborence

I found that version zsh-5.8 can prevent the space after PROMPT from being removed if the latter appears on multiple lines and we will list the contents with the tab. This can help some people if this occurs on Catalina MacOS, just for information.

Now I want to get a different configuration for the path, more a detail than a real request:

Below is an example for zsh PROMPT:

Command prompt zsh

In order to be able to see the arborenz better, I would like to change the color dynamically down to the first slash (in) ~/) of each slash in the path in blue (more precisely %F{75}) due to the color pink (%F{13}) But I want to be able to use deeper paths that would help me better localize myself in the tree.

In the picture above, this would just be a pink slash that has been changed (Phd_2019_2020/Travail_3 _…).

Here is my current PROMPT:

PROMPT='%F{13}|%F{green}%n@%F{cyan}%m%F{13}|%f%T%F{13}|%F{75}%~%F{13}|%F{7} '

Is it possible to do this dynamic color change with zsh-5.8?

If so, please let me know how to do it.

Any suggestion / track / hint is welcome.

The Linux command prompt does not work properly when the top arrow is used to display history commands

I'm trying to change my bash PS1 Variable to green color on the base name of the current directory and white on commands, below is mine PS1 Value:

 ~ echo $PS1
e[40;0;32m W e[40;0;37m

I found if with & Up arrow; The command prompt is not well displayed to get history commands

 ~ ls  anaconda-ks.cfg  dotfiles
 ~ aaaaaaaaaaaaaaaaaaaaaaaaaa
-bash: aaaaaaaaaaaaaaaaaaaaaaaaaa: command not found
 ~ aaaaaaaaaaaaaaaaaaaals

I typed here first ls, then a long line of a, then pressed twice by & Up arrow;you can see that the command prompt is Not ls but aaaaaaaaaals that is specific of aaaa and ls.

What I tried

I was trying to change PS1 Variable too W It only works this time. It shows ls Not aaaaaals

My question

What happens to it Is something wrong with mine? PS1 the settings?