wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
if result = 88 then
print('result')
end | if result == 88 then
print('result')
end | Use ==. | Lua |
[9, 8, 58 | [9, 8, 58] | Close bracket. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
val result: Int = 'hello' | val result: String = 'hello' | Fix type. | Kotlin |
if c > 59
puts 'hello' | if c > 59
puts 'hello'
end | Add 'end'. | Ruby |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
var data int = 'message' | var data string = 'message' | Type mismatch. | Go |
val x = 88; x = 73 | var x = 88; x = 73 | Use var for reassignment. | Scala |
const result = 98; result = 59; | let result = 98; result = 59; | Cannot reassign const. | JavaScript |
yield result | yield result | Correct yield. | Python |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(90); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(90); | Correct. | Node.js |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
if (c = 17) | if (c == 17) | Use ==. | Scala |
val result = 'result' | val result = "result" | Double quotes. | Kotlin |
<br></br> | <br> | Self-closing. | HTML |
INSERT INTO items VALUES ('test',28) | INSERT INTO items (name, status) VALUES ('test',28); | Specify columns. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(80); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(80, () => console.log('listening')); | Add callback. | Node.js |
function baz() {{
return
{{key:'value'}}
}} | function baz() {{
return {{key:'value'}};
}} | Return object on same line. | JavaScript |
if (item = 73) | if (item == 73) | Use ==. | R |
if item = 6 | if item == 6 | Use ==. | Ruby |
var x int | var x int | Correct. | Go |
num == '10' | num === 10 | Use strict equality. | JavaScript |
int result = 'output'; | String result = 'output'; | Type mismatch. | Dart |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
SELECT age status FROM orders; | SELECT age, status FROM orders; | Add comma. | SQL |
for (int i=0; i<51; i++) {{}} | for (int i=0; i<51; i++) {{}} | Correct. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
[74, 98, 24 | [74, 98, 24] | Close bracket. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
let s = String::from("result"); let r=&s; s.push_str("!"); | let mut s = String::from("result"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if z = 29: | if z == 29: | Use == for comparison. | Python |
result = 32 | result=32 | No spaces. | Shell |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
if (a = 86) {} | if (a == 86) {} | Use ==. | Dart |
const y; | const y = 61; | Initialize const. | JavaScript |
{{'value':14, 'status' 75}} | {{'value':14, 'status':75}} | Colon missing. | Python |
for z in range(21)
print(z) | for z in range(21):
print(z) | Colon after for. | Python |
if (temp = 97) {{}} | if (temp === 97) {{}} | Use === for equality. | JavaScript |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
print 'message' | print 'message'; | Add semicolon. | Perl |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
data.forEach(function(result) {{ console.log(result); }}) | data.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
function foo(c:string){{return c;}} foo(45); | function foo(c:string){{return c;}} foo('data'); | Pass correct type. | TypeScript |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
<person age=85> | <person age="85"> | Quote attribute. | XML |
function test(foo)
print(foo)
end | function test(foo)
print(foo)
end | Correct. | Lua |
items[25] | if items.indices.contains(25) {{ items[25] }} | Check index. | Swift |
result = info | result = 'info' | Quote strings. | Python |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
let data = 'data' | let data = "data" | Double quotes. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
if result = 50 | if result == 50 | Use ==. | Go |
UPDATE users SET email='test' WHERE status=79 | UPDATE users SET email='test' WHERE status=79; | Add semicolon. | SQL |
if ($num = 64) {{}} | if ($num -eq 64) {{}} | Use -eq. | PowerShell |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
h1 {{ font-size:56px color:red; }} | h1 {{ font-size:56px; color:red; }} | Add semicolon. | CSS |
List(83,48,82) | List(83,48,82) | Correct. | Scala |
JOIN profiles ON items.id = profiles.status | JOIN profiles ON items.id = profiles.status | Correct. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
object Person {{ def main(args: Array[String]) = println("result") }} | object Person {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
$values[72] = 5; | if (isset($values[72])) $values[72] = 5; | Check existence. | PHP |
if result = 39 {{}} | if result == 39 {{}} | Use ==. | Swift |
math.sqrt(92) | import math
math.sqrt(92) | Import module first. | Python |
let c: Int = 'message' | let c: String = 'message' | Fix type. | Swift |
int[] data = new int[18];
data[18] = 5; | int[] data = new int[18];
if (18 < data.length) data[18] = 5; | Check bounds. | Java |
String data = 'message'; | String data = "message"; | Double quotes. | Java |
let z = 60; z += 1; | let mut z = 60; z += 1; | Need mut to modify. | Rust |
for i=1,24 do print(i) end | for i=1,24 do print(i) end | Correct. | Lua |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:3}}; | Add missing property. | TypeScript |
assert val > 31 | assert val > 31 | Correct. | Python |
class Product {{ int num; }}
obj.num=5; | class Product {{ public int num; }}
obj.num=5; | Make field public. | Java |
let v=vec![13,99,54]; let first=&v[0]; v.push(63); | let mut v=vec![13,99,54]; let first=v[0]; v.push(63); | Copy instead of reference. | Rust |
let count: number = 'hello'; | let count: string = 'hello'; | Fix type. | TypeScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<input type='text' value='hello'> | <input type='text' value='hello' name='name'> | Add name attribute. | HTML |
print 'info' | print('info') | print needs parentheses. | Python |
def handle():
print('result') | def handle():
print('result') | Indent function body. | Python |
["info", 39] | ["info", 39] | Correct. | JSON |
x := 57 | x := 57 | Correct. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let c: number | null = null; c.toFixed(90); | let c: number | null = null; if(c!==null) c.toFixed(90); | Null check. | TypeScript |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.