Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7549497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:57:34+00:00 2026-05-30T09:57:34+00:00

So I have the code: intex = input(Enter in a letter of text\n) if

  • 0

So I have the code:

intex = input("Enter in a letter of text\n")
if intex == 'a' or 'b' or 'c' or 'd' or 'e' or 'f' or 'g' or 'h' or 'j' or 'k' or 'l' or 'm' or 'n' or 'o' or 'p' or 'q' or 'r':
    counter += intex
    print(counter)

By the way, all the letters are defined, I just didn’t think it was neccessary to put them in,(a = 1, b= 2, etc.) but whenever I run the code, it gives me the error TypeError: unsupported operand type(s) for +=: 'int' and 'str'

I know what this error means, that i cant add a letter to a number, but is there a way to do this without the error? i tried float(), but that gave me another error! please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:57:35+00:00Added an answer on May 30, 2026 at 9:57 am

    The or operator does not work the way you think. The expression a or b returns a if it has a trucy truth value, and to b otherwise. You probably mean

    if intex in "abcdefghijklmnopqr":
        ...
    

    To translate the letter into an integer such that a maps to 1 etc, you can use ord():

    counter += ord(intex) - ord("a") + 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have such code: function allValid() { $('input').each(function(index) { if(something) { return false; }
I have 2 text fields, user and password. When I enter the password, it
I have an html Input box to enter value used to run a PHP
So I have this code (in http://localhost/index.html ): <input type=button value=Yea class=button /> with
I have the following code in my index view. latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10] for entry
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:
in my code for index.html I use jQuery and have a link with id
Say I have jquery code like this: html += '<div class=index>' + item.index +
I have the following code: tmp_data = simulated_data[index_data]; unsigned char *dem_content_buff; dem_content_buff = new
I have found some code on measuring execution time here http://www.dreamincode.net/forums/index.php?showtopic=24685 However, it does

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.