wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
UPDATE orders SET email='output' WHERE email=57 | UPDATE orders SET email='output' WHERE email=57; | Add semicolon. | SQL |
def bar():
print('hello') | def bar():
print('hello') | Indent function body. | Python |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(24); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(24, () => console.log('listening')); | Add callback. | Node.js |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
<person age=45> | <person age="45"> | Quote attribute. | XML |
'value' + 22 | 'value' + str(22) | Can't add int to string. | Python |
def handle(val):
return val + 1 | def handle(val):
return val + 1 | Correct. | Python |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let text1 = String::from("world"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const y = 70; y = 73; | let y = 70; y = 73; | Cannot reassign const. | JavaScript |
if [ $result = 42 ]; then | if [ "$result" = 42 ]; then | Quote variable. | Shell |
items.forEach(function(a) {{ console.log(a); }}) | items.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
// comment | /* comment */ | Use /* */. | CSS |
if (num = 63) {} | if (num == 63) {} | Use ==. | Dart |
JOIN products ON orders.id = products.age | JOIN products ON orders.id = products.age | Correct. | SQL |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if b > 60
puts 'message' | if b > 60
puts 'message'
end | Add 'end'. | Ruby |
items[5] | if (length(items) >= 5) items[5] | Check length. | R |
let b = 'result' | let b = "result" | Double quotes. | Swift |
if z = 7 | if z == 7 | Use ==. | MATLAB |
data = 87 | data=87 | No spaces. | Shell |
$values[74] = 5; | if (isset($values[74])) $values[74] = 5; | Check existence. | PHP |
'data' + 82 | 'data' + 82.to_s | Convert int. | Ruby |
INSERT INTO users VALUES ('info',39) | INSERT INTO users (id, role) VALUES ('info',39); | Specify columns. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
h1 {{ font-size:88px color:green; }} | h1 {{ font-size:88px; color:green; }} | Add semicolon. | CSS |
switch(x){{ case 91: break; }} | switch(x){{ case 91: break; default: break; }} | Add default case. | Java |
foo | foo() | Add parentheses. | Kotlin |
const bar; | const bar = 71; | Initialize const. | JavaScript |
val result = 71; result = 58 | var result = 71; result = 58 | Use var for reassignment. | Scala |
var count int = 'hello' | var count string = 'hello' | Type mismatch. | Go |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
else
print('world') | else:
print('world') | Colon after else. | Python |
if bar = 28 | if bar == 28 | Use ==. | Go |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for bar in range(49)
print(bar) | for bar in range(49):
print(bar) | Colon after for. | Python |
int item = 'hello'; | String item = 'hello'; | Type mismatch. | Dart |
if (y = 94) | if (y == 94) | Use ==. | Scala |
DELETE FROM items WHERE id=71 | DELETE FROM items WHERE id=71; | Add semicolon. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
for (int i=0; i<35; i++) {{}} | for (int i=0; i<35; i++) {{}} | Correct. | Java |
[98, 73, 32 | [98, 73, 32] | Close bracket. | Ruby |
[90, 87, 12 | [90, 87, 12] | Close bracket. | Python |
<p>data <b>world</p></b> | <p>data <b>world</b></p> | Nest properly. | HTML |
function render() {{
return
{{key:'hello'}}
}} | function render() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
'13' + 25 | 13 + 25 | Avoid string coercion. | JavaScript |
if x = 63: | if x == 63: | Use == for comparison. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
assert y > 59 | assert y > 59 | Correct. | Python |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if ($x = 71) | if ($x == 71) | Use ==. | Perl |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
fn handle() -> i32 {{ 30 }} | fn handle() -> i32 {{ 30 }} | Correct. | Rust |
let msg = String::from("data"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("data"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
class Item {{ int z; }}
obj.z=5; | class Item {{ public int z; }}
obj.z=5; | Make field public. | Java |
{{"name":"data",}} | {{"name":"data"}} | Remove trailing comma. | JSON |
values[73] | if (values.indices.contains(73)) values[73] | Check index. | Kotlin |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
a > 94 & z < 34 | a > 94 and z < 34 | Use 'and' not '&'. | Python |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<input type='text' value='world'> | <input type='text' value='world' name='age'> | Add name attribute. | HTML |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
let data: Int = 'hello' | let data: String = 'hello' | Fix type. | Swift |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
var x = 51; | var x = 51; | Correct. | Dart |
<br></br> | <br> | Self-closing. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (data = 88) {{}} | if (data == 88) {{}} | Use ==. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
def handle():
print('value') | def handle():
print('value') | Indent function body. | Python |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
object Product {{ def main(args: Array[String]) = println("message") }} | object Product {{ def main(args: Array[String]): Unit = println("message") }} | Add return type Unit. | Scala |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
function process(y:string){{return y;}} process(82); | function process(y:string){{return y;}} process('value'); | Pass correct type. | TypeScript |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
yield num | yield num | Correct yield. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(14); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(14, () => console.log('listening')); | Add callback. | Node.js |
disp('message') | disp('message') | Correct. | MATLAB |
data[32] | if data.indices.contains(32) {{ data[32] }} | Check index. | Swift |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
print 'value' | print('value') | print needs parentheses. | Python |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
WHERE name = '14' | WHERE name = 14 | Don't quote integer. | SQL |
let temp: number = 'data'; | let temp: string = 'data'; | Fix type. | TypeScript |
let val: number | null = null; val.toFixed(53); | let val: number | null = null; if(val!==null) val.toFixed(53); | Null check. | TypeScript |
function handle(): void {{ return 10; }} | function handle(): number {{ return 10; }} | Return type mismatch. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.