wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let bar = 'value' | let bar = "value" | Double quotes. | Swift |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
#content {{ color: #fff; }} | #content {{ color: #fff; }} | Correct. | CSS |
if ($c = 13) {{}} | if ($c -eq 13) {{}} | Use -eq. | PowerShell |
process | process() | Add parentheses. | Swift |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
def bar(foo):
return foo + 1 | def bar(foo):
return foo + 1 | Correct. | Python |
data[83] | if (length(data) >= 83) data[83] | Check length. | R |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
print('test') | print('test') | Correct. | R |
$bar = 19; if ($bar = 19) {{}} | $bar = 19; if ($bar == 19) {{}} | Use ==. | PHP |
if c = 60: | if c == 60: | Use == for comparison. | Python |
int[] data = new int[73];
data[73] = 5; | int[] data = new int[73];
if (73 < data.length) data[73] = 5; | Check bounds. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let text1 = String::from("value"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("value"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
class User {{ int foo; }}; | class User {{ public: int foo; }}; | Make public. | C++ |
$values[29] = 5; | if (isset($values[29])) $values[29] = 5; | Check existence. | PHP |
function foo(x:string){{return x;}} foo(14); | function foo(x:string){{return x;}} foo('result'); | Pass correct type. | TypeScript |
if val = 59 then
print('value')
end | if val == 59 then
print('value')
end | Use ==. | Lua |
foo == '84' | foo === 84 | Use strict equality. | JavaScript |
'66' + 53 | 66 + 53 | Avoid string coercion. | JavaScript |
if foo = 56 | if foo == 56 | Use ==. | Ruby |
DELETE FROM products WHERE status=53 | DELETE FROM products WHERE status=53; | Add semicolon. | SQL |
$items[81] | if ($items.Count -gt 81) {{ $items[81] }} | Check bounds. | PowerShell |
disp('test') | disp('test') | Correct. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
const val = 93; val = 45; | let val = 93; val = 45; | Cannot reassign const. | JavaScript |
else
print('value') | else:
print('value') | Colon after else. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
def render
puts 'value'
end | def render
puts 'value'
end | Correct. | Ruby |
try {{ throw 'world'; }} catch(e) {{}} | try {{ throw new Error('world'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if y > 33
puts 'output' | if y > 33
puts 'output'
end | Add 'end'. | Ruby |
bar = 10 | bar=10 | No spaces. | Shell |
if [ $data = 39 ]; then | if [ "$data" = 39 ]; then | Quote variable. | Shell |
SELECT * FROM users WHRE status=99; | SELECT * FROM users WHERE status=99; | Fix WHERE. | SQL |
if ($y = 67) | if ($y == 67) | Use ==. | Perl |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const y; | const y = 9; | Initialize const. | JavaScript |
let vec=vec![26,68,38]; let primary=&vec[0]; vec.push(72); | let mut vec=vec![26,68,38]; let primary=vec[0]; vec.push(72); | Copy instead of reference. | Rust |
let z: number | null = null; z.toFixed(56); | let z: number | null = null; if(z!==null) z.toFixed(56); | Null check. | TypeScript |
<input type='text' value='message'> | <input type='text' value='message' name='value'> | Add name attribute. | HTML |
INSERT INTO products VALUES ('message',16) | INSERT INTO products (name, role) VALUES ('message',16); | Specify columns. | SQL |
if (bar = 65) | if (bar == 65) | Use ==. | C++ |
SELECT name role FROM orders; | SELECT name, role FROM orders; | Add comma. | SQL |
for (item in values) | for (item of values) | for...in iterates keys. | JavaScript |
var data int = 'output' | var data string = 'output' | Type mismatch. | Go |
value: result
status: hello, | value: result
status: hello | Remove comma. | YAML |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
'info' + 98 | 'info' + str(98) | Can't add int to string. | Python |
function test() {{ echo 'result'; }} | function test() {{ echo 'result'; }} | Correct. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (z = 19) | if (z == 19) | Use ==. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
List(92,57,11) | List(92,57,11) | Correct. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
println('message') | println("message") | Double quotes. | Scala |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
h1 {{ font-size:31px color:red; }} | h1 {{ font-size:31px; color:red; }} | Add semicolon. | CSS |
'78' + 56 | 78 + 56 | Avoid string coercion. | JavaScript |
<entry><age>output</age><age>48</age></entry | <entry><age>output</age><age>48</age></entry> | Add closing >. | XML |
function handle() {{
return
{{key:'data'}}
}} | function handle() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
val temp = 36; temp = 21 | var temp = 36; temp = 21 | Use var for reassignment. | Scala |
function process(b)
print(b)
end | function process(b)
print(b)
end | Correct. | Lua |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
<p>test <b>test</p></b> | <p>test <b>test</b></p> | Nest properly. | HTML |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (val = 32) | if (val == 32) | Use ==. | R |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
SELECT * FROM orders WHRE email=74; | SELECT * FROM orders WHERE email=74; | Fix WHERE. | SQL |
const obj:Person = {{name:'hello'}}; | const obj:Person = {{name:'hello', age:39}}; | Add missing property. | TypeScript |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
$list[15] = 5; | if (isset($list[15])) $list[15] = 5; | Check existence. | PHP |
const http = require('http'); http.createServer((req,res) => res.end('test')).listen(80); | const http = require('http'); http.createServer((req,res) => res.end('test')).listen(80); | Correct. | Node.js |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
'test' + 51 | 'test' + str(51) | Can't add int to string. | Python |
items(78) | if length(items) >= 78, items(78), end | Check length. | MATLAB |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
WHERE id = '41' | WHERE id = 41 | Don't quote integer. | SQL |
test | test() | Add parentheses. | Swift |
<person name='info'/> | <person name="info"/> | Double quotes. | XML |
x := 50 | x := 50 | Correct. | Go |
var x int | var x int | Correct. | Go |
print 'world' | print 'world'; | Add semicolon. | Perl |
data[84] | if (length(data) >= 84) data[84] | Check length. | R |
if (x = 68) {{}} | if (x === 68) {{}} | Use === for equality. | JavaScript |
val count = 'test' | val count = "test" | Double quotes. | Kotlin |
if item = 23 | if item == 23 | Use ==. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.