简体   繁体   English

我正在尝试验证用户输入是数字还是在给定范围内,试图删除以前单元格的历史记录

[英]i am trying to validiate a user input whether its is a number or in a given range,trying to remove the history of previous cells

在此处输入图像描述

This is the, I am trying to validate a user input whether it is a number or in a given range, but every time it's not in the range or its a word, it creates a new cell to input a number, want to clear the history of previous cells, how?这就是,我正在尝试验证用户输入是数字还是给定范围内,但是每次它不在范围内或不在一个单词中时,它都会创建一个新单元格来输入数字,想要清除以前的细胞史,怎么样?

def validiating_user():
    accepted_range = range(0,10)
    within_ranges = False
    r = 'abcd'
    while r.isdigit() == False or within_ranges == False:
        r = input('Plase input a number(0-10): ')
        if r.isdigit() == False:
            print('Please enter a number,not words')
        if r.isdigit() == True:
            if int(r) in accepted_range:
                within_ranges = True
            else:
                print('Please enter a number in range(0-10)')

    return int(r)

print(validiating_user())

Try adding this to your code.尝试将此添加到您的代码中。

import os

os.system('clear') # Where you would like to have the screen cleared

Please try this请试试这个

import os

clear_os = lambda: os.system('clear')
clear_os()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我对烧瓶很陌生,我正在尝试编写一个测试程序,该程序显示 1 到给定数字范围内的数字 - i am very new to flask and i am trying to write a test program that displays numbers in the range of 1 to the given number 我正在尝试对列表进行分段,然后根据给定的输入值删除重复项? 但是我错过了一些东西 - I am trying to segment the list and then remove duplicates according to the given input values ? However I am missing something #Python 新手。 我正在尝试使用 While 循环从用户那里获取输入后打印数字 - #Python newbee. I am trying to print number after taking input from user using While loop 在尝试提供用户输入时,我遇到ValueError:在尝试 - While trying to provide user input, I am Getting ValueError: need more than 0 values to unpack while trying to 我正在尝试制作一个循环,但它不工作 - i am trying to make a loop but its not working 代码不起作用。 我试图点击页面上带有 id 号的元素,但我不能 - Code not working. I am trying to click an element on a page with its id number but i cant 尝试检查用户通过输入function输入的数字是否在数字范围内 - Trying to check if the number the user entered through the input function is within a range of numbers 尝试计算用户输入中的单词数 - Trying to count the number of words from user input 我的代码有什么错误? 我正在尝试使用 function 从给定的数组中找到最大的数字 - What is the error in my code? I am trying to use the function to find the biggest number from the array given 我正在尝试调试给定的python代码,但给出了给定的错误 - I am trying to debug python code given but it gives the error as given
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM