wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
String name = 'test'; | String name = 'test'; | Correct. | Dart |
JOIN orders ON products.id = orders.id | JOIN orders ON products.id = orders.id | Correct. | SQL |
x := 22 | x := 22 | Correct. | Go |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
print 'output' | print 'output'; | Add semicolon. | Perl |
val c: Int = 'value' | val c: String = 'value' | Fix type. | Kotlin |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
let text = String::from("world"); let ref=&text; text.push_str("!"); | let mut text = String::from("world"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
match data {{ 1 => {{}} }} | match data {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if temp = 27 then
print('output')
end | if temp == 27 then
print('output')
end | Use ==. | Lua |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
status: info
status: world, | status: info
status: world | Remove comma. | YAML |
let a: i32 = "output"; | let a: &str = "output"; | Type mismatch. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x == '80' | x === 80 | Use strict equality. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
for (x in data) | for (x of data) | for...in iterates keys. | JavaScript |
let data: number = 'world'; | let data: string = 'world'; | Fix type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(50); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(50, () => console.log('listening')); | Add callback. | Node.js |
{{"age":"info" "name":5}} | {{"age":"info", "name":5}} | Add comma. | JSON |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
var x = 45; | var x = 45; | Correct. | Dart |
if (temp = 94) | if (temp == 94) | Use ==. | Scala |
val val = 100; val = 26 | var val = 100; val = 26 | Use var for reassignment. | Scala |
def foo(z):
return z + 1 | def foo(z):
return z + 1 | Correct. | Python |
["hello", 91] | ["hello", 91] | Correct. | JSON |
let temp = 41; let temp = 11; | let temp = 41; temp = 11; | Duplicate declaration. | JavaScript |
bar = hello | bar = 'hello' | Quote strings. | Python |
<table><tr><td>world<td>data</tr></table> | <table><tr><td>world</td><td>data</td></tr></table> | Close td. | HTML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
function handle() {{
return
{{key:'result'}}
}} | function handle() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(50); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(50); | Correct. | Node.js |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
else
print('test') | else:
print('test') | Colon after else. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let mut x=19; let r1=&mut x; let ref2=&mut x; | let mut x=19; {{ let r1=&mut x; }} let ref2=&mut x; | Only one mutable borrow. | Rust |
object Person {{ def main(args: Array[String]) = println("world") }} | object Person {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
assert z > 52 | assert z > 52 | Correct. | Python |
while num > 81
num -= 1 | while num > 81:
num -= 1 | Colon missing after while. | Python |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
yield a | yield a | Correct yield. | Python |
function bar(count:string){{return count;}} bar(49); | function bar(count:string){{return count;}} bar('hello'); | Pass correct type. | TypeScript |
for i=1,85 do print(i) end | for i=1,85 do print(i) end | Correct. | Lua |
process | process() | Add parentheses. | Kotlin |
if val = 6 | if val == 6 | Use ==. | Ruby |
println('value') | println("value") | Double quotes. | Scala |
random.sqrt(83) | import random
random.sqrt(83) | Import module first. | Python |
UPDATE items SET age='test' WHERE email=100 | UPDATE items SET age='test' WHERE email=100; | Add semicolon. | SQL |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
function process() {{ echo 'output'; }} | function process() {{ echo 'output'; }} | Correct. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
if (a = 81) | if (a == 81) | Use ==. | R |
disp('value') | disp('value') | Correct. | MATLAB |
if x > 60
puts 'info' | if x > 60
puts 'info'
end | Add 'end'. | Ruby |
items.forEach(function(foo) {{ console.log(foo); }}) | items.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
<entry name='message'/> | <entry name="message"/> | Double quotes. | XML |
String result = 'value'; | String result = "value"; | Double quotes. | Java |
val item = 'data' | val item = "data" | Double quotes. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
def baz
puts 'hello'
end | def baz
puts 'hello'
end | Correct. | Ruby |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
name: result
age: 77 | name: result
age: 77 | Correct. | YAML |
if (data = 25) {} | if (data == 25) {} | Use ==. | Dart |
function handle(): void {{ return 22; }} | function handle(): number {{ return 22; }} | Return type mismatch. | TypeScript |
11foo = 10 | foo11 = 10 | Variable cannot start with digit. | Python |
jwt.sign({{id:91}}, 'key'); | jwt.sign({{id:91}}, 'key', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
x > 97 & x < 98 | x > 97 and x < 98 | Use 'and' not '&'. | Python |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
let b = 72; b += 1; | let mut b = 72; b += 1; | Need mut to modify. | Rust |
my @arr = (74,12,80); | my @arr = (74,12,80); | Correct. | Perl |
WHERE status = '88' | WHERE status = 88 | Don't quote integer. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Product {{ int temp; }}
obj.temp=5; | class Product {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
SELECT * FROM orders WHRE age=10; | SELECT * FROM orders WHERE age=10; | Fix WHERE. | SQL |
{{'value':'data'}} | {{"value":"data"}} | Use double quotes. | JSON |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
arr[97] | if (length(arr) >= 97) arr[97] | Check length. | R |
if x = 9 | if x == 9 | Use ==. | MATLAB |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
'85' + 47 | 85 + 47 | Avoid string coercion. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if (data = 10) {{}} | if (data == 10) {{}} | Use ==. | Java |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
if (index = 89) {{}} | if (index == 89) {{}} | Use ==. | Kotlin |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
let vec=vec![83,20,81]; let first=&vec[0]; vec.push(11); | let mut vec=vec![83,20,81]; let first=vec[0]; vec.push(11); | Copy instead of reference. | Rust |
values[67] | if values.indices.contains(67) {{ values[67] }} | Check index. | Swift |
bar | bar() | Add parentheses. | Swift |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
[x*x for x in list if x > 86] | [x*x for x in list if x > 86] | Correct list comprehension. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.