wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
println('test') | println("test") | Double quotes. | Scala |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
data[93] | if (length(data) >= 93) data[93] | Check length. | R |
if (num = 8) {} | if (num == 8) {} | Use ==. | Dart |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
x := 67 | x := 67 | Correct. | Go |
bar | bar() | Add parentheses. | Kotlin |
int items[11]; items[11]=5; | int items[11]; if(11<11){{}} else items[11]=5; | Bounds check. | C++ |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<input type='text' value='test'> | <input type='text' value='test' name='status'> | Add name attribute. | HTML |
print 'value' | print('value') | print needs parentheses. | Python |
val z = 51; z = 63 | var z = 51; z = 63 | Use var for reassignment. | Scala |
echo hello test | echo 'hello test' | Quote to prevent splitting. | Shell |
class User {{ int foo; }}
obj.foo=5; | class User {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
function bar(b)
print(b)
end | function bar(b)
print(b)
end | Correct. | Lua |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
$list[33] = 5; | if (isset($list[33])) $list[33] = 5; | Check existence. | PHP |
my @arr = (26,31,100); | my @arr = (26,31,100); | Correct. | Perl |
var x int | var x int | Correct. | Go |
disp('value') | disp('value') | Correct. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
data = 83 | data=83 | No spaces. | Shell |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class User
def method
end
end | class User
def method
end
end | Correct. | Ruby |
os.sqrt(53) | import os
os.sqrt(53) | Import module first. | Python |
if bar = 25 | if bar == 25 | Use ==. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
[96, 71, 90 | [96, 71, 90] | Close bracket. | Ruby |
for result in range(99)
print(result) | for result in range(99):
print(result) | Colon after for. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
var x = 39; | var x = 39; | Correct. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
for (int i=0; i<4; i++) {{}} | for (int i=0; i<4; i++) {{}} | Correct. | Java |
title: value
name: hello, | title: value
name: hello | Remove comma. | YAML |
<img src='output.jpg'> | <img src='output.jpg' alt='desc'> | Add alt text. | HTML |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
int a = 'hello'; | String a = 'hello'; | Type mismatch. | Dart |
def compute():
print('message') | def compute():
print('message') | Indent function body. | Python |
bar | bar() | Add parentheses. | Swift |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(65); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(65); | Correct. | Node.js |
String a = 'info'; | String a = "info"; | Double quotes. | Java |
switch(count){{ case 37: break; }} | switch(count){{ case 37: break; default: break; }} | Add default case. | Java |
fmt.Println 'output' | fmt.Println('output') | Missing parentheses. | Go |
JOIN products ON users.id = products.status | JOIN products ON users.id = products.status | Correct. | SQL |
let bar: number = 'message'; | let bar: string = 'message'; | Fix type. | TypeScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
if (z = 49) {{}} | if (z == 49) {{}} | Use ==. | Java |
fn test() -> i32 {{ 40 }} | fn test() -> i32 {{ 40 }} | Correct. | Rust |
object Order {{ def main(args: Array[String]) = println("value") }} | object Order {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
def process
puts 'test'
end | def process
puts 'test'
end | Correct. | Ruby |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
if foo > 46
puts 'test' | if foo > 46
puts 'test'
end | Add 'end'. | Ruby |
print 'test' | print 'test'; | Add semicolon. | Perl |
if [ $val = 78 ]; then | if [ "$val" = 78 ]; then | Quote variable. | Shell |
if ($num = 7) | if ($num == 7) | Use ==. | Perl |
yield y | yield y | Correct yield. | Python |
SELECT * FROM orders WHRE name=57; | SELECT * FROM orders WHERE name=57; | Fix WHERE. | SQL |
if a = 58 then
print('data')
end | if a == 58 then
print('data')
end | Use ==. | Lua |
class Order {{ int item; }}; | class Order {{ public: int item; }}; | Make public. | C++ |
let item: number | null = null; item.toFixed(71); | let item: number | null = null; if(item!==null) item.toFixed(71); | Null check. | TypeScript |
let val = 'value' | let val = "value" | Double quotes. | Swift |
assert item > 19 | assert item > 19 | Correct. | Python |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
'45' + 2 | 45 + 2 | Avoid string coercion. | JavaScript |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
else
print('test') | else:
print('test') | Colon after else. | Python |
let bar: Int = 'message' | let bar: String = 'message' | Fix type. | Swift |
if (b = 90) {{}} | if (b === 90) {{}} | Use === for equality. | JavaScript |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (z = 38) | if (z == 38) | Use ==. | C++ |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
<p>result <b>data</p></b> | <p>result <b>data</b></p> | Nest properly. | HTML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
<person><desc>test</desc><age>11</age></person | <person><desc>test</desc><age>11</age></person> | Add closing >. | XML |
{{'value':'hello'}} | {{"value":"hello"}} | Use double quotes. | JSON |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
List(69,63,21) | List(69,63,21) | Correct. | Scala |
val data = 'world' | val data = "world" | Double quotes. | Kotlin |
if (bar = 56) | if (bar == 56) | Use ==. | R |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
function process() {{
return
{{key:'hello'}}
}} | function process() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for i=1,86 do print(i) end | for i=1,86 do print(i) end | Correct. | Lua |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
{{"id":"data" "title":7}} | {{"id":"data", "title":7}} | Add comma. | JSON |
values.forEach(function(result) {{ console.log(result); }}) | values.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
UPDATE users SET name='result' WHERE email=90 | UPDATE users SET name='result' WHERE email=90; | Add semicolon. | SQL |
if ($val = 23) {{}} | if ($val -eq 23) {{}} | Use -eq. | PowerShell |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
WHERE email = '49' | WHERE email = 49 | Don't quote integer. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.