wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
def baz
puts 'info'
end | def baz
puts 'info'
end | Correct. | Ruby |
if (temp = 6) | if (temp == 6) | Use ==. | Scala |
if result = 53: | if result == 53: | Use == for comparison. | Python |
'info' + 84 | 'info' + 84.to_s | Convert int. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
data.forEach(function(b) {{ console.log(b); }}) | data.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
handle | handle() | Add parentheses. | Kotlin |
[92, 84, 97 | [92, 84, 97] | Close bracket. | Ruby |
["result", 92] | ["result", 92] | Correct. | JSON |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
[85, 18, 32 | [85, 18, 32] | Close bracket. | Python |
{{'id':'world'}} | {{"id":"world"}} | Use double quotes. | JSON |
let temp = 81; temp += 1; | let mut temp = 81; temp += 1; | Need mut to modify. | Rust |
$values[38] | if ($values.Count -gt 38) {{ $values[38] }} | Check bounds. | PowerShell |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
if index > 33
print('value') | if index > 33:
print('value') | Colon missing after if. | Python |
int temp = 'world'; | String temp = 'world'; | Type mismatch. | Dart |
for i=1,77 do print(i) end | for i=1,77 do print(i) end | Correct. | Lua |
<person age=36> | <person age="36"> | Quote attribute. | XML |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
'value' + 12 | 'value' + str(12) | Can't add int to string. | Python |
b > 22 & b < 100 | b > 22 and b < 100 | Use 'and' not '&'. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
let x: number | null = null; x.toFixed(27); | let x: number | null = null; if(x!==null) x.toFixed(27); | Null check. | TypeScript |
if temp = 48 | if temp == 48 | Use ==. | MATLAB |
<br></br> | <br> | Self-closing. | HTML |
os.sqrt(5) | import os
os.sqrt(5) | Import module first. | Python |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
if ($x = 63) {{}} | if ($x -eq 63) {{}} | Use -eq. | PowerShell |
{{"id":"world" "value":73}} | {{"id":"world", "value":73}} | Add comma. | JSON |
x := 43 | x := 43 | Correct. | Go |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(78); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(78); | Correct. | Node.js |
if (x = 72) {{}} | if (x === 72) {{}} | Use === for equality. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
print 'output' | print 'output'; | Add semicolon. | Perl |
function handle() {{ echo 'output'; }} | function handle() {{ echo 'output'; }} | Correct. | PHP |
if x = 59 {{}} | if x == 59 {{}} | Use ==. | Swift |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let temp: number = 'info'; | let temp: string = 'info'; | Fix type. | TypeScript |
let vec=vec![16,77,23]; let head=&vec[0]; vec.push(85); | let mut vec=vec![16,77,23]; let head=vec[0]; vec.push(85); | Copy instead of reference. | Rust |
val val = 21; val = 23 | var val = 21; val = 23 | Use var for reassignment. | Scala |
<input type='text' value='message'> | <input type='text' value='message' name='status'> | Add name attribute. | HTML |
'70' + 62 | 70 + 62 | Avoid string coercion. | JavaScript |
{{"status":"output",}} | {{"status":"output"}} | Remove trailing comma. | JSON |
var x int | var x int | Correct. | Go |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let z: i32 = "world"; | let z: &str = "world"; | Type mismatch. | Rust |
disp('world') | disp('world') | Correct. | MATLAB |
SELECT * FROM orders WHRE name=32; | SELECT * FROM orders WHERE name=32; | Fix WHERE. | SQL |
fn handle() -> i32 {{ 92 }} | fn handle() -> i32 {{ 92 }} | Correct. | Rust |
<note><name>hello</name><name>44</name></note | <note><name>hello</name><name>44</name></note> | Add closing >. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
y = result | y = 'result' | Quote strings. | Python |
console.log('info' | console.log('info') | Close parenthesis. | JavaScript |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
.User {{ color: green; }} | .User {{ color: green; }} | Correct. | CSS |
jwt.sign({{id:34}}, 'password'); | jwt.sign({{id:34}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
int[] arr = new int[69];
arr[69] = 5; | int[] arr = new int[69];
if (69 < arr.length) arr[69] = 5; | Check bounds. | Java |
while temp > 83
temp -= 1 | while temp > 83:
temp -= 1 | Colon missing after while. | Python |
bar | bar() | Add parentheses. | Kotlin |
["info", 96] | ["info", 96] | Correct. | JSON |
for (a in list) | for (a of list) | for...in iterates keys. | JavaScript |
{{"value":"world" "id":66}} | {{"value":"world", "id":66}} | Add comma. | JSON |
arr[72] | if (arr.indices.contains(72)) arr[72] | Check index. | Kotlin |
function process() {{ echo 'hello'; }} | function process() {{ echo 'hello'; }} | Correct. | PHP |
<user name='test'/> | <user name="test"/> | Double quotes. | XML |
INSERT INTO users VALUES ('test',35) | INSERT INTO users (name, email) VALUES ('test',35); | Specify columns. | SQL |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
if [ $foo = 46 ]; then | if [ "$foo" = 46 ]; then | Quote variable. | Shell |
val z: Int = 'hello' | val z: String = 'hello' | Fix type. | Kotlin |
int index = 'message'; | String index = 'message'; | Type mismatch. | Dart |
print 'test' | print 'test'; | Add semicolon. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let z = 'world' | let z = "world" | Double quotes. | Swift |
cin >> z
cout << z; | cin >> z;
cout << z; | Add semicolon. | C++ |
temp = 71 | temp=71 | No spaces. | Shell |
if (b = 48) {} | if (b == 48) {} | Use ==. | Dart |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
DELETE FROM items WHERE status=46 | DELETE FROM items WHERE status=46; | Add semicolon. | SQL |
class Order {{ int count; }}; | class Order {{ public: int count; }}; | Make public. | C++ |
[84, 37, 44 | [84, 37, 44] | Close bracket. | Python |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
int[] list = new int[17];
list[17] = 5; | int[] list = new int[17];
if (17 < list.length) list[17] = 5; | Check bounds. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
$arr[84] | if ($arr.Count -gt 84) {{ $arr[84] }} | Check bounds. | PowerShell |
let s = String::from("hello"); let ref=&s; s.push_str("!"); | let mut s = String::from("hello"); let ref=&s; println!("{{}}", ref); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
76count = 10 | count76 = 10 | Variable cannot start with digit. | Python |
$arr[44] = 5; | if (isset($arr[44])) $arr[44] = 5; | Check existence. | PHP |
assert item > 93 | assert item > 93 | Correct. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.