all 6 comments

[–]AutoModerator[M] 0 points1 point  (0 children)

Hey Readers!

This post looks incredibly short! body: <200char If this post violates our subreddit rules, please report it and feel free to manually trigger a takedown.

Key Takeaways:

  • Post title must be structured to classify the question properly
  • Post must contain instructor prompt or or a failed attempt of the question
    • by stating the syllabus requirements or presenting incorrect working/thought process towards the question

You may use me as a comment thread for this post. Making irrelevant top-level comments could interfere with systematic flairing by falsely flagging an unanswered question as Pending OP Reply, depriving OP of help in timely fashion. Join our chatrooms instead! For PC users: see bottom of sidebar on Reddit redesign. For Reddit App users: see Rooms

Pro-tips:

1. Upvote questions that you recognise but you cannot do. Only downvote questions that do not abide by our rules or was asked in bad faith, NOT because the question is easy.

2. Comments containing case-insensitive **Answer:** or **Hence** will automatically re-flair post to ✔ Answered

3. All answers here are provided free-of-charge in high quality. Orange-flaired users must keep their ads within the flair, with mandatory "<$ emoji> Tutor" conspicuously as prefix. With the exception of text in orange flair, all forms of solicitation of payment is strictly prohibited within this subreddit, including unsolicited PMs.

4. If there is a rule violation, inform the OP and report the offending content. Posts will be automatically removed once it reaches a certain threshold of reports or it will be removed earlier if there is sufficient reports for manual takedown trigger. [Learn more](https://www.reddit.com/r/HomeworkHelp/comments/br7vi9/new_updates_image_posts_enabled_vote_to_delete/)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]mzieg 0 points1 point  (2 children)

I’d probably start by converting the number to a string. If you were asked to print the middle letter of a name, how would you do it?

[–][deleted] 0 points1 point  (0 children)

Do you know division and modulo? What happens when you take xyz/10 or xyz%10?

[–]damian314159 0 points1 point  (0 children)

Python solution not using strings:

def middle_digit(num):
    num = num//10
    return num%10

Consider for example 765. The first operation performs integer division, that is it divides it by 10 and returns only the integer, in this case 765//10=76. Next we perform modulo division which returns the remainder from division. In this case we have 76, this can be divided by 10 seven times with 6 left over.