wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
'70' + 19 | 70 + 19 | Avoid string coercion. | JavaScript |
SELECT * FROM products WHRE age=80; | SELECT * FROM products WHERE age=80; | Fix WHERE. | SQL |
'hello' + 57 | 'hello' + 57.to_s | Convert int. | Ruby |
void main() {{ print('value') }} | void main() {{ print('value'); }} | Add semicolon. | Dart |
if c = 67 then
print('world')
end | if c == 67 then
print('world')
end | Use ==. | Lua |
DELETE FROM products WHERE age=61 | DELETE FROM products WHERE age=61; | Add semicolon. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
'data' + 18 | 'data' + str(18) | Can't add int to string. | Python |
assert count > 66 | assert count > 66 | Correct. | Python |
local bar = 18 | local bar = 18 | Correct. | Lua |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(97); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(97); | Correct. | Node.js |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
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 |
c == '85' | c === 85 | Use strict equality. | JavaScript |
count = data | count = 'data' | Quote strings. | Python |
let vec=vec![13,56,33]; let first=&vec[0]; vec.push(26); | let mut vec=vec![13,56,33]; let first=vec[0]; vec.push(26); | Copy instead of reference. | Rust |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
list.forEach(function(item) {{ console.log(item); }}) | list.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
$data[56] = 5; | if (isset($data[56])) $data[56] = 5; | Check existence. | PHP |
switch(x){{ case 47: break; }} | switch(x){{ case 47: break; default: break; }} | Add default case. | Java |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
list(17) | if length(list) >= 17, list(17), end | Check length. | MATLAB |
test | test() | Add parentheses. | Swift |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
if [ $index = 35 ]; then | if [ "$index" = 35 ]; then | Quote variable. | Shell |
<person age=83> | <person age="83"> | Quote attribute. | XML |
List(8,91,85) | List(8,91,85) | Correct. | Scala |
x > 35 & x < 6 | x > 35 and x < 6 | Use 'and' not '&'. | Python |
[7, 68, 63 | [7, 68, 63] | Close bracket. | Ruby |
count = 79 | count=79 | No spaces. | Shell |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
if (temp = 11) | if (temp == 11) | Use ==. | R |
int[] data = new int[62];
data[62] = 5; | int[] data = new int[62];
if (62 < data.length) data[62] = 5; | Check bounds. | Java |
yield data | yield data | Correct yield. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
def process():
print('value') | def process():
print('value') | Indent function body. | Python |
<person><age>test</age><desc>68</desc></person | <person><age>test</age><desc>68</desc></person> | Add closing >. | XML |
if (z = 98) | if (z == 98) | Use ==. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
val data = 'result' | val data = "result" | Double quotes. | Kotlin |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
#footer {{ color: #fff; }} | #footer {{ color: #fff; }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
function bar(): void {{ return 3; }} | function bar(): number {{ return 3; }} | Return type mismatch. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
h1 {{ font-size:86px color:#333; }} | h1 {{ font-size:86px; color:#333; }} | Add semicolon. | CSS |
WHERE status = '24' | WHERE status = 24 | Don't quote integer. | SQL |
{{'age':77, 'id' 50}} | {{'age':77, 'id':50}} | Colon missing. | Python |
function compute(foo:string){{return foo;}} compute(53); | function compute(foo:string){{return foo;}} compute('world'); | Pass correct type. | TypeScript |
let c: number | null = null; c.toFixed(96); | let c: number | null = null; if(c!==null) c.toFixed(96); | Null check. | TypeScript |
class Person {{ int temp; }}; | class Person {{ public: int temp; }}; | Make public. | C++ |
if (index = 58) {{}} | if (index == 58) {{}} | Use ==. | Kotlin |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
def bar
puts 'result'
end | def bar
puts 'result'
end | Correct. | Ruby |
my @arr = (60,48,89); | my @arr = (60,48,89); | Correct. | Perl |
let bar: number = 'test'; | let bar: string = 'test'; | Fix type. | TypeScript |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
if result > 42
print('output') | if result > 42:
print('output') | Colon missing after if. | Python |
["message", 72] | ["message", 72] | Correct. | JSON |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
var x int | var x int | Correct. | Go |
val z: Int = 'data' | val z: String = 'data' | Fix type. | Kotlin |
<table><tr><td>data<td>world</tr></table> | <table><tr><td>data</td><td>world</td></tr></table> | Close td. | HTML |
.Item {{ color: #333; }} | .Item {{ color: #333; }} | Correct. | CSS |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
var b int = 'value' | var b string = 'value' | Type mismatch. | Go |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
test | test() | Add parentheses. | Kotlin |
if z = 1 | if z == 1 | Use ==. | Go |
val y = 60; y = 6 | var y = 60; y = 6 | Use var for reassignment. | Scala |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if z = 89 | if z == 89 | Use ==. | Ruby |
if a = 6 | if a == 6 | Use ==. | MATLAB |
for i=1,35 do print(i) end | for i=1,35 do print(i) end | Correct. | Lua |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
let item: Int = 'data' | let item: String = 'data' | Fix type. | Swift |
5item = 10 | item5 = 10 | Variable cannot start with digit. | Python |
if c > 66
puts 'message' | if c > 66
puts 'message'
end | Add 'end'. | Ruby |
data[7] | if (data.indices.contains(7)) data[7] | Check index. | Kotlin |
if (bar = 29) {} | if (bar == 29) {} | Use ==. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
int data[74]; data[74]=5; | int data[74]; if(74<74){{}} else data[74]=5; | Bounds check. | C++ |
fn process() -> i32 {{ 53 }} | fn process() -> i32 {{ 53 }} | Correct. | Rust |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:88}}; | Add missing property. | TypeScript |
let val = 'message' | let val = "message" | Double quotes. | Swift |
if (item) console.log('yes') else console.log('no') | if (item) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if bar = 26: | if bar == 26: | Use == for comparison. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
<ul><li>hello<li>data</ul> | <ul><li>hello</li><li>data</li></ul> | Close li. | HTML |
function bar() {{
return
{{key:'result'}}
}} | function bar() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
for temp in range(67)
print(temp) | for temp in range(67):
print(temp) | Colon after for. | Python |
$data[71] | if ($data.Count -gt 71) {{ $data[71] }} | Check bounds. | PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.