trying to advance from java to Python with no luck so i want to write this simple java code in python, but i cant, i want to print all the Strings letters form the first index to the last, so if my string is "josh", i want to print:  j  o  s h   or like this java code:     String name = josh;    for(int i = 0; i &lt; josh.length(); i++){    print(josh.CharAt(i));  }   i cant find any method that is like charAt, i'm guessing that it doesn't exists but there has to some other way to do it, i know its kinda dumb question, but i couldn't find anything online or here(on this website) to help me, so any ideas?
Iterating each character in a string using Python In C++, I can iterate over an std::string like this:  std::string str = "Hello World!";  for (int i = 0; i &lt; str.length(); ++i) {     std::cout &lt;&lt; str[i] &lt;&lt; std::endl; }   How do I iterate over a string in Python?
Using a diode to ensure current flows in only one direction, without causing a voltage drop To power my microcontroller (ATmega8), I am using a ~5.4V voltage source. I want to ensure that I don't accidentally connect the voltage source in reverse, and figured a diode would be a nice way to accomplish this as from what I have learned so far, a diode allows current to flow in one direction, and blocks it in the other.  But what I also learned is that diodes create drops in voltage. I have a few of the typical diodes (1N4001, 1N4148, etc.), and would like to use them to achieve the aforementioned result without dropping the voltage as it would be too low to power the IC.  My question is, is there any way to do this with a diode? Or do I need some other component (if so, what would you recommend)? How did Google find my unlinked newly created pages? I am building a new site, but creating the content using a subdirectory on an existing site. I have never posted a link to this subdirectory anywhere, yet searching Google reveals that Google has found these pages on my site and indexed them.  Further, I updated the site with a robots.txt file that WMT reports as being read, and testing the blocked pages using the WMT test tool indicates that the pages will not be indexed. Apparently this does not remove the pages from existing results, though I submitted a request to do so.  How did Google find these pages to begin with? Is it because I used a common subdirectory name and Google guesses at common subdirectories? If I have flagged a post, show me a "flags" link in my profile What is the fate of the Asgardians at the start of Avengers: Infinity War? In $\mathbb{Z}/(n)$, does $(a) = (b)$ imply that $a$ and $b$ are associates? [Update: Based on the hints provided by @zcn and @whacka, I believe I have found a solution. See my answer below.]  Below, $R$ is a commutative ring with $1$.  In John J. Watkins' Topics in Commutative Ring Theory, the author observes that if $a$ and $b$ are associates in $R$, then they generate the same ideal: $(a) = (b)$. This is clearly true, because $a = ub$ and $b = va$ for some units $u$ and $v$, and so $a \in (b)$ and $b \in (a)$, whence $(a) \subset (b)$ and $(b) \subset (a)$. Indeed, we didn't even require $u$ and $v$ to be units to reach this conclusion.  The author then claims that if $R$ is not a domain, then the converse may not be true: we may have $(a) = (b)$ even if $a$ and $b$ are not associates. As a "counterexample" he gives $R = \mathbb{Z}/(6)$, with $a = 2 + (6)$ and $b = 4 + (6)$. Clearly these elements generate the same ideal: $(a) = (b) = \{0, 2 + (6), 4 + (6)\}$. The author asserts that $a$ and $b$ are not associates, but this is false: $5 + (6)$ is a unit, and $(2 + (6))(5 + (6)) = 4 + (6)$, so $a$ and $b$ actually are associates.  I figured that the author botched the example but that surely the basic fact must be true: if $R = \mathbb{Z}/(n)$ then there may be nonassociates $a,b \in R$ with $(a) = (b)$. However, I was not able to find a counterexample and eventually resorted to writing a computer program and found that there are no counterexamples in $\mathbb{Z}/(n)$ for $n \leq 100$.  So now I'm starting to think that there is no counterexample in $\mathbb{Z}/(n)$ at all, but I have not yet been able to prove this.  My questions:   If I am correct that $(a) = (b)$ in $\mathbb{Z}/(n)$ implies that $a$ and $b$ are associates, I would appreciate a nudge in the right direction toward a proof. (But if the proof is elementary, please give only a hint, not a solution :-) I'll post my solution once I have one. In either case, could you please point me to a genuine counterexample? If there is one in $\mathbb{Z}/(n)$ for some $n$, that would be ideal (no pun intended), otherwise a counterexample in any commutative ring with $1$ would be great. "Add" button doesn't work with JavaScript off I'm using stackoverflow.com with JavaScript off. I accept this comes with somewhat less functionality, however for the most part SO works fine.  If I look at the home page (), every single button on there except for two types works with JS off.  The first second is that the "x Votes; y answers;z views" mouse-over indicates they're links but clicking them does nothing. This one is less of an issue because the user can still click the question title, and they're only implied buttons anyway.  The second (and bigger) issue is the "Add" buttons next to "Favorite Tags" and "Ignored Tags". These are explicit buttons that don't do anything with JS off. There is no working JS substitute for them (the "tag subscriptions" link itself works, but the page it goes to doesn't work with JS off, but that's another bug report). How to redirect stderr and stdout to different files and also display in terminal? Installed MySQL but still says command not found I downloaded MySQL's rpm bundle from the site, converted it to a .deb file using alien and installed it by saying sudo dpkg -i mysql-server_5.6.14-2_amd64.deb. However, when I say mysql in the command line, it gives an error that it is not installed. What do I do?  I am on Ubuntu GNOME 13.10 64-bit Dropping z dimension programmatically It seems there is no geoalgorithm to drop z values in the QGIS processing toolbox. Can this be done programmatically using the Python console? At the moment I have to save the layer with unchecked 'Include z-dimension' checkbox (non automatic geometry type): Over the past couple of days there have been a few questions about overlapping proposals and questions that could belong on multiple sites:        What is the best practice before / after asking a question if you think your question might be better on another site?  or  If I think my question might belong on multiple sites as per the above posts? A coin with heads probability $p$ is flipped $n$ times. A "run" is a maximal sequence of consecutive flips that are all the same. For example, the sequence HTHHHTTH with $n=8$ has five runs, namely H, T, HHH, TT,H. Show that the expected number of runs is  $$1+2(n-1)p(1-p).$$  I have tried to use some generating function on this but calculus got pretty messy and didn't work. Escape velocity from long ladder How can I contribute to Ubuntu? I would like to know what kinds of contributions someone can make to Ubuntu. Such as Programmer, User, Proofreader, etc. My pixel perfect picture gets blurry when compiled in LaTeX I have this picture:  (I have the original in Pixen and could export it to several different formats. I went with PNG though since it's lossless.)  When I open my picture in Preview (OS X) and zoom in, it looks fine. The characters have extremely sharp boarders between them and the background. However, when I put it into my LaTeX document, compile it to a PDF (using TeXShop) and then zoom in, it suddenly have gotten blurry (see screenshot: ).  Minimal working example:  \documentclass[12pt]{article} \usepackage{graphicx} \begin{document} \includegraphics[scale=1]{fig1.png} \end{document}   In the end, I would like to be able to scale the picture freely without there being any blurring at all. How to get the path of a running JAR file? Where To start Learning With Salesforce Development Does Python have a ternary conditional operator? How come the PHP private class var is not private? Is it grammatically  wrong  to say      It's been too hot  in the last / the past few days      It's been too hot for the last / the past few days     I saw this following sentence also, can we omit in it?     He's had two new cars in the last / in the past three years   as     He's had two new cars  the last / in the past three years     Is there a strict rule in using of preposition or non-preposition when we use the last/past ?  What is the structure when I refer to weeks, months ? Recently, on my Ubuntu 18.04 I have noticed that at least on gnome-calculator and chromium browser the fonts are displayed as squares. I have followed instructions  and , the calculator is fixed, but the problem on chromium still exists when I open a dialog to search for a file.  Not sure if this happens on other applications as well, I haven't checked all my apps, but File managers nemo and nautilus are working fine.  Also, before few months ago, I have included some windows fonts for my libre office shown . I used the copy (cp) method, not the link (ln -s). But, was working fine until yesterday. Haven't done any major change or update, at least on my Linux partition (dual boot). But, I don't think that this has anything to do with that.  Any idea how can I fix this issue?  .