Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2018
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question Trying to assign a numeric value input as length

    Currently im working on a lab project where i need to utilize a for loop and while loop to execute over a length that has to be defined by numeric input. Getting the code to execute print function over the loop isnt what im having a difficult time with. what i cant seem to figure out is how to take a numeric input and have it assigned as the length for my loops. any pointers would be greatly appreciated. to answer the obvious question before it is asked yes i am new to programming.

  2. #2
    Regular Coder
    Join Date
    Oct 2015
    Posts
    407
    Thanks
    1
    Thanked 49 Times in 46 Posts
    Getting and using user input varies with the language used, what language are you using and how far have you got with your code?

  3. Users who have thanked wha for this post:

    Ouroborous (Oct 8th, 2018)

  4. #3
    New to the CF scene
    Join Date
    Oct 2018
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    We are using python and we just finished covering while and for loops and are moving on to nested loops.
    Last edited by vinyl-junkie; Oct 8th, 2018 at 10:02 AM. Reason: thread moved to Python forum

  5. #4
    New to the CF scene
    Join Date
    Oct 2018
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    as my current code stands i managed to work in a line that allowed me to do what i needed it to do but am still trying to understand the exact process of turning numeric input into length for loops.

  6. #5
    Regular Coder
    Join Date
    Oct 2015
    Posts
    407
    Thanks
    1
    Thanked 49 Times in 46 Posts
    How exactly do you want to know the process?

    Essentially (superficially), what is going on is Python requests key-presses from the operating system buffer, placing them into your variable and translates this into a number if needed. It will struggle to do this if non-numeric keys are pressed.

    The idea of using a high level language is that we don't need to know the mechanics, just that it does all this for us.

  7. Users who have thanked wha for this post:

    Ouroborous (Oct 9th, 2018)

  8. #6
    New to the CF scene
    Join Date
    Oct 2018
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts
    thank you for the assist.


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •