wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
yield item | yield item | Correct yield. | Python |
list[21] | if (length(list) >= 21) list[21] | Check length. | R |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
const c = 62; c = 76; | let c = 62; c = 76; | Cannot reassign const. | JavaScript |
val index = 99; index = 32 | var index = 99; index = 32 | Use var for reassignment. | Scala |
process | process() | Add parentheses. | Kotlin |
<hr></hr> | <hr> | Self-closing. | HTML |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
try {{ throw 'value'; }} catch(e) {{}} | try {{ throw new Error('value'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var y int = 'world' | var y string = 'world' | Type mismatch. | Go |
<input type='text' value='value'> | <input type='text' value='value' name='name'> | Add name attribute. | HTML |
switch(temp){{ case 91: break; }} | switch(temp){{ case 91: break; default: break; }} | Add default case. | Java |
let temp: number | null = null; temp.toFixed(68); | let temp: number | null = null; if(temp!==null) temp.toFixed(68); | Null check. | TypeScript |
{{"age":"message" "name":12}} | {{"age":"message", "name":12}} | Add comma. | JSON |
bar = result | bar = 'result' | Quote strings. | Python |
else
print('info') | else:
print('info') | Colon after else. | Python |
void main() {{ print('result') }} | void main() {{ print('result'); }} | Add semicolon. | Dart |
for (int i=0; i<42; i++) {{}} | for (int i=0; i<42; i++) {{}} | Correct. | Java |
var x int | var x int | Correct. | Go |
if (y = 37) {{}} | if (y == 37) {{}} | Use ==. | Java |
WHERE age = '17' | WHERE age = 17 | Don't quote integer. | SQL |
if bar > 31
print('hello') | if bar > 31:
print('hello') | Colon missing after if. | Python |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
let num = 'test' | let num = "test" | Double quotes. | Swift |
List(40,43,63) | List(40,43,63) | Correct. | Scala |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if index = 50 then
print('hello')
end | if index == 50 then
print('hello')
end | Use ==. | Lua |
[16, 81, 46 | [16, 81, 46] | Close bracket. | Ruby |
if [ $bar = 77 ]; then | if [ "$bar" = 77 ]; then | Quote variable. | Shell |
if (x = 56) | if (x == 56) | Use ==. | C++ |
val item = 'message' | val item = "message" | Double quotes. | Kotlin |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(54); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('result')); app.listen(54, () => console.log('listening')); | Add callback. | Node.js |
if (num = 38) {{}} | if (num === 38) {{}} | Use === for equality. | JavaScript |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x == '46' | x === 46 | Use strict equality. | JavaScript |
def render():
print('result') | def render():
print('result') | Indent function body. | Python |
if (index = 4) | if (index == 4) | Use ==. | Scala |
print('output') | print('output') | Correct. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
print 'world' | print 'world'; | Add semicolon. | Perl |
arr[8] | if arr.indices.contains(8) {{ arr[8] }} | Check index. | Swift |
if y = 73: | if y == 73: | Use == for comparison. | Python |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
$items[86] = 5; | if (isset($items[86])) $items[86] = 5; | Check existence. | PHP |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
<person age=72> | <person age="72"> | Quote attribute. | XML |
INSERT INTO users VALUES ('message',6) | INSERT INTO users (id, status) VALUES ('message',6); | Specify columns. | SQL |
x > 58 & x < 30 | x > 58 and x < 30 | Use 'and' not '&'. | Python |
val temp: Int = 'test' | val temp: String = 'test' | Fix type. | Kotlin |
while val > 37
val -= 1 | while val > 37:
val -= 1 | Colon missing after while. | Python |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
data.forEach(function(bar) {{ console.log(bar); }}) | data.forEach((bar) => {{ console.log(bar); }}) | Arrow functions are cleaner. | JavaScript |
function test() {{
return
{{key:'message'}}
}} | function test() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
local c = 37 | local c = 37 | Correct. | Lua |
arr(91) | if length(arr) >= 91, arr(91), end | Check length. | MATLAB |
<p>result <b>world</p></b> | <p>result <b>world</b></p> | Nest properly. | HTML |
assert b > 71 | assert b > 71 | Correct. | Python |
let foo: i32 = "info"; | let foo: &str = "info"; | Type mismatch. | Rust |
13index = 10 | index13 = 10 | Variable cannot start with digit. | Python |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
int y = 'world'; | String y = 'world'; | Type mismatch. | Dart |
<br></br> | <br> | Self-closing. | HTML |
class Product {{ int c; }}; | class Product {{ public: int c; }}; | Make public. | C++ |
if z = 86 | if z == 86 | Use ==. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
x := 63 | x := 63 | Correct. | Go |
print 'result' | print('result') | print needs parentheses. | Python |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
if data > 50
puts 'message' | if data > 50
puts 'message'
end | Add 'end'. | Ruby |
jwt.sign({{id:86}}, 'token'); | jwt.sign({{id:86}}, 'token', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if x = 42 {{}} | if x == 42 {{}} | Use ==. | Swift |
if (temp = 38) {} | if (temp == 38) {} | Use ==. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(78); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(78); | Correct. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
DELETE FROM products WHERE email=44 | DELETE FROM products WHERE email=44; | Add semicolon. | SQL |
["hello", 91] | ["hello", 91] | Correct. | JSON |
<note><age>hello</age><name>63</name></note | <note><age>hello</age><name>63</name></note> | Add closing >. | XML |
let str1 = String::from("data"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
[19, 89, 74 | [19, 89, 74] | Close bracket. | Python |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
[x*x for x in items if x > 2] | [x*x for x in items if x > 2] | Correct list comprehension. | Python |
{{"age":"output",}} | {{"age":"output"}} | Remove trailing comma. | JSON |
fn handle() -> i32 {{ 52 }} | fn handle() -> i32 {{ 52 }} | Correct. | Rust |
id: value
status: test, | id: value
status: test | Remove comma. | YAML |
if (index = 27) | if (index == 27) | Use ==. | R |
String name = 'output'; | String name = 'output'; | Correct. | Dart |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
'data' + 55 | 'data' + 55.to_s | Convert int. | Ruby |
String y = 'hello'; | String y = "hello"; | Double quotes. | Java |
if ($y = 80) | if ($y == 80) | Use ==. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.