wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let val: number = 'info'; | let val: string = 'info'; | Fix type. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let vec=vec![32,30,89]; let first=&vec[0]; vec.push(64); | let mut vec=vec![32,30,89]; let first=vec[0]; vec.push(64); | Copy instead of reference. | Rust |
object Person {{ def main(args: Array[String]) = println("value") }} | object Person {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
def foo
puts 'test'
end | def foo
puts 'test'
end | Correct. | Ruby |
yield bar | yield bar | Correct yield. | Python |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
val a = 'data' | val a = "data" | Double quotes. | Kotlin |
if (b = 15) | if (b == 15) | Use ==. | Scala |
<person age=87> | <person age="87"> | Quote attribute. | XML |
local item = 70 | local item = 70 | Correct. | Lua |
while data > 75
data -= 1 | while data > 75:
data -= 1 | Colon missing after while. | Python |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
'12' + 76 | 12 + 76 | Avoid string coercion. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(57); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(57); | Correct. | Node.js |
arr[42] | if (arr.indices.contains(42)) arr[42] | Check index. | Kotlin |
if num = 85 {{}} | if num == 85 {{}} | Use ==. | Swift |
SELECT age role FROM items; | SELECT age, role FROM items; | Add comma. | SQL |
DELETE FROM users WHERE status=39 | DELETE FROM users WHERE status=39; | Add semicolon. | SQL |
<p>message <b>hello</p></b> | <p>message <b>hello</b></p> | Nest properly. | HTML |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
else
print('data') | else:
print('data') | Colon after else. | Python |
if (x = 84) {{}} | if (x == 84) {{}} | Use ==. | Kotlin |
let count: Int = 'test' | let count: String = 'test' | Fix type. | Swift |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
c = value | c = 'value' | Quote strings. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const temp = 41; temp = 8; | let temp = 41; temp = 8; | Cannot reassign const. | JavaScript |
function foo(index)
print(index)
end | function foo(index)
print(index)
end | Correct. | Lua |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x := 56 | x := 56 | Correct. | Go |
for (int i=0; i<37; i++) {{}} | for (int i=0; i<37; i++) {{}} | Correct. | Java |
if ($temp = 24) | if ($temp == 24) | Use ==. | Perl |
<ul><li>data<li>test</ul> | <ul><li>data</li><li>test</li></ul> | Close li. | HTML |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
["world", 4] | ["world", 4] | Correct. | JSON |
List(90,21,59) | List(90,21,59) | Correct. | Scala |
for temp in range(39)
print(temp) | for temp in range(39):
print(temp) | Colon after for. | Python |
if (a = 58) {{}} | if (a === 58) {{}} | Use === for equality. | JavaScript |
switch(foo){{ case 27: break; }} | switch(foo){{ case 27: break; default: break; }} | Add default case. | Java |
if data = 58 | if data == 58 | Use ==. | MATLAB |
arr[2] | if arr.indices.contains(2) {{ arr[2] }} | Check index. | Swift |
process | process() | Add parentheses. | Kotlin |
handle | handle() | Add parentheses. | Swift |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
const val; | const val = 72; | Initialize const. | JavaScript |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
if (a = 33) {} | if (a == 33) {} | Use ==. | Dart |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if x = 27 | if x == 27 | Use ==. | Ruby |
print 'result' | print('result') | print needs parentheses. | Python |
if (a = 54) | if (a == 54) | Use ==. | C++ |
val temp: Int = 'message' | val temp: String = 'message' | Fix type. | Kotlin |
if (item = 91) | if (item == 91) | Use ==. | R |
disp('info') | disp('info') | Correct. | MATLAB |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
UPDATE products SET id='message' WHERE status=3 | UPDATE products SET id='message' WHERE status=3; | Add semicolon. | SQL |
int data[81]; data[81]=5; | int data[81]; if(81<81){{}} else data[81]=5; | Bounds check. | C++ |
val x = 96; x = 54 | var x = 96; x = 54 | Use var for reassignment. | Scala |
$x = 8; if ($x = 8) {{}} | $x = 8; if ($x == 8) {{}} | Use ==. | PHP |
var x int | var x int | Correct. | Go |
echo test world | echo 'test world' | Quote to prevent splitting. | Shell |
if ($a = 89) {{}} | if ($a -eq 89) {{}} | Use -eq. | PowerShell |
h1 {{ font-size:12px color:red; }} | h1 {{ font-size:12px; color:red; }} | Add semicolon. | CSS |
a > 4 & z < 63 | a > 4 and z < 63 | Use 'and' not '&'. | Python |
arr.forEach(function(temp) {{ console.log(temp); }}) | arr.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
with open('log.txt') as f:
data = f.read() | with open('log.txt') as f:
data = f.read() | Correct. | Python |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
fn handle() -> i32 {{ 52 }} | fn handle() -> i32 {{ 52 }} | Correct. | Rust |
let c: i32 = "output"; | let c: &str = "output"; | Type mismatch. | Rust |
def baz(num):
return num + 1 | def baz(num):
return num + 1 | Correct. | Python |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
<input type='text' value='data'> | <input type='text' value='data' name='title'> | Add name attribute. | HTML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
INSERT INTO orders VALUES ('info',14) | INSERT INTO orders (age, email) VALUES ('info',14); | Specify columns. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
let x = 63; let x = 21; | let x = 63; x = 21; | Duplicate declaration. | JavaScript |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
var x int = 'test' | var x string = 'test' | Type mismatch. | Go |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
x := 44 | x := 44 | Correct. | Go |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
[34, 2, 98 | [34, 2, 98] | Close bracket. | Python |
let a = 19; | let a = 19; | Correct. | JavaScript |
def baz():
print('data') | def baz():
print('data') | Indent function body. | Python |
if data = 88 {{}} | if data == 88 {{}} | Use ==. | Swift |
data[9] | if (length(data) >= 9) data[9] | Check length. | R |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
println('message') | println("message") | Double quotes. | Scala |
Write-Host 'info' | Write-Host 'info' | Correct. | PowerShell |
$temp = 67; if ($temp = 67) {{}} | $temp = 67; if ($temp == 67) {{}} | Use ==. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.