1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Lostsunrise [7]
3 years ago
5

I need to reverse a inputted word using for loops with range 0 to the input word and increment 1.

Computers and Technology
1 answer:
Ksivusya [100]3 years ago
4 0

fruit_name = input("What is your favorite fruit: ")

fruit_len = len(fruit_name)

fruit_len = int(fruit_len)

reversed_word = ""

lower = 0

upper = fruit_len

inc = 1

for lp in range(lower, upper, inc):

   reversed_word = (fruit_name[lp] + reversed_word)

   reversed_word = str(reversed_word)

print(fruit_name + " backwards is " + reversed_word)

I just changed the str(lp) to fruit_name[lp]. This takes lp as the index of fruit_name and gets the letter at that index. We then add that letter to the existing reversed_word. I think this is what you're looking for.

You might be interested in
g The reciprocal Fibonacci constant ψ is defined by the infinite sum: ψ=∑n=1 [infinity] 1 Fn Where Fn are the Fibonacci numbers
timama [110]

Answer:

see explaination

Explanation:

MATLAB script:

% MATLAB script that calculates reciprocal Fibonacci constant Ψ

% Initial Values

a0 = 1;

a1 = 1;

% Looping variable

i = 2;

% Reading n value from user

n = input(' Enter n value: ');

% Initializing sum

sum = (1/a0) + (1/a1);

% Loop till i reaches n value

while i <= n

% Finding term in Fibnocii series

a2 = a0 + a1;

% Accumulating Sum

sum = sum + (1/a2);

% Updating previous terms

a0 = a1;

a1 = a2;

% Incrementing loop variable

i = i + 1;

endwhile

% Printing result

printf("\n Reciprocol Fibnocii Constant: %f \n", sum);

See attachment for sample output

5 0
3 years ago
While your hands are on home row, your left hand rests lightly on _____.
In-s [12.5K]
The answer is b. asdfc.  
8 0
3 years ago
Read 2 more answers
Numeric data is stored in what for direct processing
Ede4ka [16]
A string variables??? I'm not sure does this have any multiple choice 
3 0
3 years ago
When giving a presentation it is better to ___________
Romashka-Z-Leto [24]
<span>C) Always better to give your information and end on time.</span>
6 0
3 years ago
What are the five types of alignment in word?
valentinak56 [21]
I know of four,
Left-aligned
Center-aligned
right-aligned
justified

5 0
4 years ago
Read 2 more answers
Other questions:
  • Ryan is looking at investment opportunities as a cloud service provider. He wants to invest in a deployment-based cloud model th
    11·2 answers
  • Please help will mark brainiest
    8·1 answer
  • The local emergency manager has the responsibility for coordinating emergency management programs and activities. A local emerge
    7·1 answer
  • A tracking signal A. is computed as the mean absolute deviation​ (MAD) divided by the running sum of the forecast errors​ (RSFE)
    10·1 answer
  • What will you see on the next line?
    6·2 answers
  • Can someone please help me to point out what's wrong with this C program:
    13·1 answer
  • A school has an intranet for the staff and students to use. Some of the files stored on the intranet are confidential. Give two
    15·1 answer
  • I just wanna know how many times a day y'all hit the tutor button at the bottom
    10·2 answers
  • How does a fully integrated Data and Analytics Platform enable organizations to convert data into consumable information and ins
    15·1 answer
  • What will be the output, if any, when the user clicks the right mouse button?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!