how do i write this code (easy way), python problem?



  • I am very new in Python, and I am really surprised at the following line of code.

    p, q = [int(x) for x in input().split()]
    
    

    how to write basic??



  • You can make a loop instead to understand better, but the code won't work because the logic is false:

    your_input = input().split() 
    list_ = []
    for x in your_input:
        list_.append(int(x))
    p, q = list_
    
    

    The .split() put the str in input in a list so you just have one element and one loop. But the p,q = at the end suggests it waits two elements in the list. So it can't work. Maybe you can delete the .split() if you want each digit of a number less than 100. Depends on the result you want.


Log in to reply
 

最新帖子

最新内容

  • S

    You can use Mongoose 'remove' middleware.

    For example:

    authorSchema.pre('remove', (next) => { storySchema.remove({authorSchema_id: this._id}).exec(); next(); });

    And documentation.

    read more
  • S

    Since it involves directly interacting with Mongoose and MongoDB, I'd suggest doing it in Mongoose middleware. Here's how you'd remove all the stories from a certain Author object:

    let myAuthor = new Author(/* all the props */); myAuthor.stories = [];

    read more
  • S

    I have this schema in mongoose. I want to delete a author that will deletes all author's stories. is best way to do that in middleware express or middleware mongoose? thanks

    const authorSchema = new Schema ({ name : String, stories : [{ type : ObjectId, ref:'Story'}] }) const storySchema = new Schema({ title : String })

    read more
  • S

    my friends, I have about 200 ajax handlers, I designed one part of the app that keeps the application in maintenance. My question is, how can I disable all AJAX handlers for normal users (non-admin users)? Normally, I need to check the user capability in every method, which is timed operations.

    read more
  • S

    Use angualr universal in your application to make your app SEO friendly

    run below command on your root:

    ng add @ng-toolkit/universal

    Next, when you run your application by ng serve command you need to run below command:

    npm run build:prod npm run server

    Now check the view source in your browser you can find HTML with SEO content like below:

    read more

推荐阅读